Skip to content

Commit

Permalink
caching
Browse files Browse the repository at this point in the history
  • Loading branch information
patriot1burke committed Feb 19, 2016
1 parent fd49213 commit c45524d
Show file tree
Hide file tree
Showing 63 changed files with 1,403 additions and 1,549 deletions.
Expand Up @@ -23,7 +23,7 @@
}, },


"userCache": { "userCache": {
"infinispan" : { "default" : {
"enabled": true "enabled": true
} }
}, },
Expand Down Expand Up @@ -61,15 +61,15 @@
}, },


"realmCache": { "realmCache": {
"provider": "infinispan-locking", "provider": "default",
"infinispan-locking" : { "default" : {
"enabled": true "enabled": true
} }
}, },


"connectionsInfinispan": { "connectionsInfinispan": {
"provider": "locking", "provider": "default",
"locking": { "default": {
"cacheContainer" : "java:comp/env/infinispan/Keycloak" "cacheContainer" : "java:comp/env/infinispan/Keycloak"
} }
} }
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.infinispan.manager.DefaultCacheManager; import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.transaction.LockingMode; import org.infinispan.transaction.LockingMode;
import org.infinispan.transaction.TransactionMode;
import org.infinispan.transaction.lookup.DummyTransactionManagerLookup; import org.infinispan.transaction.lookup.DummyTransactionManagerLookup;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.keycloak.Config; import org.keycloak.Config;
Expand Down Expand Up @@ -154,6 +155,15 @@ protected void initEmbedded() {
} }
Configuration replicationCacheConfiguration = replicationConfigBuilder.build(); Configuration replicationCacheConfiguration = replicationConfigBuilder.build();
cacheManager.defineConfiguration(InfinispanConnectionProvider.WORK_CACHE_NAME, replicationCacheConfiguration); cacheManager.defineConfiguration(InfinispanConnectionProvider.WORK_CACHE_NAME, replicationCacheConfiguration);

ConfigurationBuilder counterConfigBuilder = new ConfigurationBuilder();
counterConfigBuilder.invocationBatching().enable()
.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
counterConfigBuilder.transaction().transactionManagerLookup(new DummyTransactionManagerLookup());
counterConfigBuilder.transaction().lockingMode(LockingMode.PESSIMISTIC);
Configuration counterCacheConfiguration = counterConfigBuilder.build();

cacheManager.defineConfiguration(InfinispanConnectionProvider.VERSION_CACHE_NAME, counterCacheConfiguration);
} }


} }
Expand Up @@ -25,6 +25,7 @@
*/ */
public interface InfinispanConnectionProvider extends Provider { public interface InfinispanConnectionProvider extends Provider {


public static final String VERSION_CACHE_NAME = "realmVersions";
static final String REALM_CACHE_NAME = "realms"; static final String REALM_CACHE_NAME = "realms";
static final String USER_CACHE_NAME = "users"; static final String USER_CACHE_NAME = "users";
static final String SESSION_CACHE_NAME = "sessions"; static final String SESSION_CACHE_NAME = "sessions";
Expand Down
Expand Up @@ -45,7 +45,7 @@ public ClientAdapter(RealmModel cachedRealm, CachedClient cached, CacheRealmProv


private void getDelegateForUpdate() { private void getDelegateForUpdate() {
if (updated == null) { if (updated == null) {
cacheSession.registerApplicationInvalidation(getId()); cacheSession.registerClientInvalidation(getId());
updated = cacheSession.getDelegate().getClientById(getId(), cachedRealm); updated = cacheSession.getDelegate().getClientById(getId(), cachedRealm);
if (updated == null) throw new IllegalStateException("Not found in database"); if (updated == null) throw new IllegalStateException("Not found in database");
} }
Expand Down Expand Up @@ -377,7 +377,6 @@ public String getClientId() {
public void setClientId(String clientId) { public void setClientId(String clientId) {
getDelegateForUpdate(); getDelegateForUpdate();
updated.setClientId(clientId); updated.setClientId(clientId);
cacheSession.registerRealmInvalidation(cachedRealm.getId());
} }


@Override @Override
Expand Down

0 comments on commit c45524d

Please sign in to comment.