Search in sources :

Example 26 with RemoteCache

use of org.infinispan.client.hotrod.RemoteCache in project keycloak by keycloak.

the class InfinispanSingleUseTokenStoreProviderFactory method getActionTokenCache.

static Supplier getActionTokenCache(KeycloakSession session) {
    InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
    Cache cache = connections.getCache(InfinispanConnectionProvider.ACTION_TOKEN_CACHE);
    RemoteCache remoteCache = InfinispanUtil.getRemoteCache(cache);
    if (remoteCache != null) {
        LOG.debugf("Having remote stores. Using remote cache '%s' for single-use cache of token", remoteCache.getName());
        return () -> {
            // Doing this way as flag is per invocation
            return remoteCache.withFlags(Flag.FORCE_RETURN_VALUE);
        };
    } else {
        LOG.debugf("Not having remote stores. Using normal cache '%s' for single-use cache of token", cache.getName());
        return () -> {
            return cache;
        };
    }
}
Also used : RemoteCache(org.infinispan.client.hotrod.RemoteCache) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) Cache(org.infinispan.Cache) RemoteCache(org.infinispan.client.hotrod.RemoteCache) BasicCache(org.infinispan.commons.api.BasicCache)

Aggregations

RemoteCache (org.infinispan.client.hotrod.RemoteCache)26 SessionEntityWrapper (org.keycloak.models.sessions.infinispan.changes.SessionEntityWrapper)9 Cache (org.infinispan.Cache)8 Map (java.util.Map)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 HotRodClientException (org.infinispan.client.hotrod.exceptions.HotRodClientException)5 RemoteStore (org.infinispan.persistence.remote.RemoteStore)5 UUID (java.util.UUID)4 BasicCache (org.infinispan.commons.api.BasicCache)4 Logger (org.jboss.logging.Logger)4 KeycloakSession (org.keycloak.models.KeycloakSession)4 RealmModel (org.keycloak.models.RealmModel)4 UserSessionEntity (org.keycloak.models.sessions.infinispan.entities.UserSessionEntity)4 HashMap (java.util.HashMap)3 Objects (java.util.Objects)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 TimeUnit (java.util.concurrent.TimeUnit)3 BiFunction (java.util.function.BiFunction)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3