Search in sources :

Example 1 with InvalidationEvent

use of org.keycloak.models.cache.infinispan.events.InvalidationEvent in project keycloak by keycloak.

the class InfinispanCacheStoreFactoryProviderFactory method lazyInit.

private void lazyInit(KeycloakSession session) {
    if (storeCache == null) {
        synchronized (this) {
            if (storeCache == null) {
                Cache<String, Revisioned> cache = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.AUTHORIZATION_CACHE_NAME);
                Cache<String, Long> revisions = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.AUTHORIZATION_REVISIONS_CACHE_NAME);
                storeCache = new StoreFactoryCacheManager(cache, revisions);
                ClusterProvider cluster = session.getProvider(ClusterProvider.class);
                cluster.registerListener(AUTHORIZATION_INVALIDATION_EVENTS, (ClusterEvent event) -> {
                    InvalidationEvent invalidationEvent = (InvalidationEvent) event;
                    storeCache.invalidationEventReceived(invalidationEvent);
                });
                cluster.registerListener(AUTHORIZATION_CLEAR_CACHE_EVENTS, (ClusterEvent event) -> storeCache.clear());
                cluster.registerListener(REALM_CLEAR_CACHE_EVENTS, (ClusterEvent event) -> storeCache.clear());
                log.debug("Registered cluster listeners");
            }
        }
    }
}
Also used : ClusterEvent(org.keycloak.cluster.ClusterEvent) Revisioned(org.keycloak.models.cache.infinispan.entities.Revisioned) ClusterProvider(org.keycloak.cluster.ClusterProvider) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) InvalidationEvent(org.keycloak.models.cache.infinispan.events.InvalidationEvent)

Example 2 with InvalidationEvent

use of org.keycloak.models.cache.infinispan.events.InvalidationEvent in project keycloak by keycloak.

the class InfinispanUserCacheProviderFactory method lazyInit.

private void lazyInit(KeycloakSession session) {
    if (userCache == null) {
        synchronized (this) {
            if (userCache == null) {
                Cache<String, Revisioned> cache = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.USER_CACHE_NAME);
                Cache<String, Long> revisions = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.USER_REVISIONS_CACHE_NAME);
                userCache = new UserCacheManager(cache, revisions);
                ClusterProvider cluster = session.getProvider(ClusterProvider.class);
                cluster.registerListener(USER_INVALIDATION_EVENTS, (ClusterEvent event) -> {
                    InvalidationEvent invalidationEvent = (InvalidationEvent) event;
                    userCache.invalidationEventReceived(invalidationEvent);
                });
                cluster.registerListener(USER_CLEAR_CACHE_EVENTS, (ClusterEvent event) -> {
                    userCache.clear();
                });
                log.debug("Registered cluster listeners");
            }
        }
    }
}
Also used : ClusterEvent(org.keycloak.cluster.ClusterEvent) Revisioned(org.keycloak.models.cache.infinispan.entities.Revisioned) ClusterProvider(org.keycloak.cluster.ClusterProvider) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) InvalidationEvent(org.keycloak.models.cache.infinispan.events.InvalidationEvent)

Example 3 with InvalidationEvent

use of org.keycloak.models.cache.infinispan.events.InvalidationEvent in project keycloak by keycloak.

the class InfinispanCacheRealmProviderFactory method lazyInit.

private void lazyInit(KeycloakSession session) {
    if (realmCache == null) {
        synchronized (this) {
            if (realmCache == null) {
                Cache<String, Revisioned> cache = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.REALM_CACHE_NAME);
                Cache<String, Long> revisions = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.REALM_REVISIONS_CACHE_NAME);
                realmCache = new RealmCacheManager(cache, revisions);
                ClusterProvider cluster = session.getProvider(ClusterProvider.class);
                cluster.registerListener(REALM_INVALIDATION_EVENTS, (ClusterEvent event) -> {
                    InvalidationEvent invalidationEvent = (InvalidationEvent) event;
                    realmCache.invalidationEventReceived(invalidationEvent);
                });
                cluster.registerListener(REALM_CLEAR_CACHE_EVENTS, (ClusterEvent event) -> {
                    realmCache.clear();
                });
                log.debug("Registered cluster listeners");
            }
        }
    }
}
Also used : ClusterEvent(org.keycloak.cluster.ClusterEvent) Revisioned(org.keycloak.models.cache.infinispan.entities.Revisioned) ClusterProvider(org.keycloak.cluster.ClusterProvider) InfinispanConnectionProvider(org.keycloak.connections.infinispan.InfinispanConnectionProvider) InvalidationEvent(org.keycloak.models.cache.infinispan.events.InvalidationEvent)

Aggregations

ClusterEvent (org.keycloak.cluster.ClusterEvent)3 ClusterProvider (org.keycloak.cluster.ClusterProvider)3 InfinispanConnectionProvider (org.keycloak.connections.infinispan.InfinispanConnectionProvider)3 Revisioned (org.keycloak.models.cache.infinispan.entities.Revisioned)3 InvalidationEvent (org.keycloak.models.cache.infinispan.events.InvalidationEvent)3