concurrency
This commit is contained in:
parent
45e5cfac99
commit
0b54838f31
3 changed files with 20 additions and 22 deletions
|
@ -211,11 +211,12 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider {
|
|||
logger.tracev("by id cache hit: {0}", cached.getName());
|
||||
}
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
Long loaded = UpdateCounter.current();
|
||||
RealmModel model = getDelegate().getRealm(id);
|
||||
if (model == null) return null;
|
||||
if (realmInvalidations.contains(id)) return model;
|
||||
cached = new RevisionedCachedRealm(loaded, cache, this, model);
|
||||
logger.tracev("try caching realm: {0} {1}", cached.getName(), loaded);
|
||||
cache.addCachedRealm(cached);
|
||||
} else if (realmInvalidations.contains(id)) {
|
||||
return getDelegate().getRealm(id);
|
||||
|
@ -234,10 +235,12 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider {
|
|||
logger.tracev("by name cache hit: {0}", cached.getName());
|
||||
}
|
||||
if (cached == null) {
|
||||
Long loaded = UpdateCounter.current();
|
||||
RealmModel model = getDelegate().getRealmByName(name);
|
||||
if (model == null) return null;
|
||||
if (realmInvalidations.contains(model.getId())) return model;
|
||||
cached = new RevisionedCachedRealm(null, cache, this, model);
|
||||
cached = new RevisionedCachedRealm(loaded, cache, this, model);
|
||||
logger.tracev("try caching realm: {0}", cached.getName());
|
||||
cache.addCachedRealm(cached);
|
||||
} else if (realmInvalidations.contains(cached.getId())) {
|
||||
return getDelegate().getRealmByName(name);
|
||||
|
@ -299,7 +302,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
Long loaded = UpdateCounter.current();
|
||||
RoleModel model = getDelegate().getRoleById(id, realm);
|
||||
if (model == null) return null;
|
||||
if (roleInvalidations.contains(id)) return model;
|
||||
|
@ -328,7 +331,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
Long loaded = UpdateCounter.current();
|
||||
GroupModel model = getDelegate().getGroupById(id, realm);
|
||||
if (model == null) return null;
|
||||
if (groupInvalidations.contains(id)) return model;
|
||||
|
@ -356,7 +359,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
Long loaded = UpdateCounter.current();
|
||||
ClientModel model = getDelegate().getClientById(id, realm);
|
||||
if (model == null) return null;
|
||||
if (appInvalidations.contains(id)) return model;
|
||||
|
@ -379,7 +382,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider {
|
|||
}
|
||||
|
||||
if (cached == null) {
|
||||
Long loaded = cache.getCurrentRevision(id);
|
||||
Long loaded = UpdateCounter.current();
|
||||
ClientTemplateModel model = getDelegate().getClientTemplateById(id, realm);
|
||||
if (model == null) return null;
|
||||
if (clientTemplateInvalidations.contains(id)) return model;
|
||||
|
|
|
@ -51,11 +51,6 @@ public class RevisionedRealmCache implements RealmCache {
|
|||
return cache;
|
||||
}
|
||||
|
||||
public Long getCurrentRevision(String id) {
|
||||
//return revisions.get(id);
|
||||
return UpdateCounter.current();
|
||||
}
|
||||
|
||||
private <T> T get(String id, Class<T> type) {
|
||||
Revisioned o = (Revisioned)cache.get(id);
|
||||
if (o == null) {
|
||||
|
@ -83,13 +78,13 @@ public class RevisionedRealmCache implements RealmCache {
|
|||
protected void addRevisioned(String id, Revisioned object) {
|
||||
Long rev = revisions.get(id);
|
||||
if (rev == null) {
|
||||
logger.tracev("rev was null in addRevisioned, adding one");
|
||||
rev = UpdateCounter.next();
|
||||
revisions.put(id, rev);
|
||||
return;
|
||||
}
|
||||
if (rev.equals(object.getRevision())) {
|
||||
cache.putForExternalRead(id, object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,13 +32,6 @@
|
|||
}
|
||||
},
|
||||
|
||||
"realmCache": {
|
||||
"provider": "infinispan-revisioned",
|
||||
"infinispan-locking" : {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
|
||||
"timer": {
|
||||
"provider": "basic"
|
||||
},
|
||||
|
@ -85,8 +78,15 @@
|
|||
}
|
||||
},
|
||||
|
||||
"realmCache": {
|
||||
"provider": "infinispan-locking",
|
||||
"infinispan-locking" : {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
|
||||
"connectionsInfinispan": {
|
||||
"provider": "revisioned",
|
||||
"provider": "locking",
|
||||
"locking": {
|
||||
"clustered": "${keycloak.connectionsInfinispan.clustered:false}",
|
||||
"async": "${keycloak.connectionsInfinispan.async:true}",
|
||||
|
|
Loading…
Reference in a new issue