PerThreadCache: Add static convenience method
Change-Id: Id599161b12c7b0e2c39ed28f01ff769d9f71b91e
This commit is contained in:
@@ -109,14 +109,10 @@ public class DefaultPermissionBackend extends PermissionBackend {
|
||||
try {
|
||||
ProjectState state = projectCache.checkedGet(project);
|
||||
if (state != null) {
|
||||
PerThreadCache perThreadCache = PerThreadCache.get();
|
||||
if (perThreadCache == null) {
|
||||
return projectControlFactory.create(user, state).asForProject().database(db);
|
||||
}
|
||||
PerThreadCache.Key<ProjectControl> cacheKey =
|
||||
PerThreadCache.Key.create(ProjectControl.class, project, user.getCacheKey());
|
||||
ProjectControl control =
|
||||
perThreadCache.get(cacheKey, () -> projectControlFactory.create(user, state));
|
||||
PerThreadCache.getOrCompute(
|
||||
PerThreadCache.Key.create(ProjectControl.class, project, user.getCacheKey()),
|
||||
() -> projectControlFactory.create(user, state));
|
||||
return control.asForProject().database(db);
|
||||
}
|
||||
return FailedPermissionBackend.project("not found", new NoSuchProjectException(project));
|
||||
|
Reference in New Issue
Block a user