Class CacheConfigurator
java.lang.Object
org.keycloak.spi.infinispan.impl.embedded.CacheConfigurator
Utility class related to the Infinispan cache configuration.
This class contains methods to configure caches based on the SPI configuration options, and it provides cache configuration defaults.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
applyDefaultConfiguration
(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Applies the default Infinispan cache configuration to theholder
, if the cache is not present.static void
checkCachesExist
(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder, Stream<String> caches) Verifies that all thecaches
are defined in theholder
.static void
configureCacheMaxCount
(Config.Scope keycloakConfig, org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder, Stream<String> caches) Configures the maximum number of entries for the specified caches, bounding them to this limit and preventing excessive memory usage.static void
configureLocalCaches
(Config.Scope keycloakConfig, org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Configures the Infinispan local caches used by Keycloak (e.g., for realm or user data) using the provided Keycloak configuration.static void
configureSessionsCachesForPersistentSessions
(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Configures all the sessions caches when persistent user sessions feature is enabled.static void
configureSessionsCachesForVolatileSessions
(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Configures all the sessions caches when persistent user sessions feature is enabled.static org.infinispan.configuration.cache.ConfigurationBuilder
static org.infinispan.configuration.cache.ConfigurationBuilder
static org.infinispan.configuration.cache.ConfigurationBuilder
getRevisionCacheConfig
(long maxEntries) static String
maxCountConfigKey
(String name) static void
removeClusteredCaches
(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Removes clustered caches from theholder
.static void
validateWorkCacheConfiguration
(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Validates that the "work" cache is present in theholder
and has a valid configuration.
-
Method Details
-
configureLocalCaches
public static void configureLocalCaches(Config.Scope keycloakConfig, org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Configures the Infinispan local caches used by Keycloak (e.g., for realm or user data) using the provided Keycloak configuration.- Parameters:
keycloakConfig
- The Keycloak configuration.holder
- TheConfigurationBuilderHolder
where the caches will be defined.- Throws:
IllegalStateException
- if an Infinispan cache is not defined. This could indicate a missing or incorrect configuration.
-
applyDefaultConfiguration
public static void applyDefaultConfiguration(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Applies the default Infinispan cache configuration to theholder
, if the cache is not present.Each cache may have its own default configuration.
- Parameters:
holder
- TheConfigurationBuilderHolder
where the caches will be defined.
-
checkCachesExist
public static void checkCachesExist(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder, Stream<String> caches) Verifies that all thecaches
are defined in theholder
.- Parameters:
holder
- TheConfigurationBuilderHolder
where the caches are configured.caches
- TheStream
containing the names of the caches to check.- Throws:
IllegalStateException
- if one or more Infinispan caches from the providedcaches
stream are not defined in theholder
. This could indicate a missing or incorrect configuration for those specific caches.
-
validateWorkCacheConfiguration
public static void validateWorkCacheConfiguration(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Validates that the "work" cache is present in theholder
and has a valid configuration.- Parameters:
holder
- TheConfigurationBuilderHolder
where the caches are configured.- Throws:
IllegalStateException
- if the "work" cache is not found in the holder.RuntimeException
- if the "work" cache has an invalid configuration. This could include an incorrect settings that would prevent the cache from functioning correctly.
-
removeClusteredCaches
public static void removeClusteredCaches(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Removes clustered caches from theholder
.- Parameters:
holder
- TheConfigurationBuilderHolder
where the caches are configured.
-
configureCacheMaxCount
public static void configureCacheMaxCount(Config.Scope keycloakConfig, org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder, Stream<String> caches) Configures the maximum number of entries for the specified caches, bounding them to this limit and preventing excessive memory usage.- Parameters:
keycloakConfig
- The Keycloak configuration, which provides the maximum entry counts for the caches.holder
- TheConfigurationBuilderHolder
where the caches are configured.caches
- TheStream
containing the names of the caches to configure with a maximum count.- Throws:
IllegalStateException
- if an Infinispan cache from the providedcaches
stream is not defined in theholder
. This could indicate a missing or incorrect configuration.
-
configureSessionsCachesForPersistentSessions
public static void configureSessionsCachesForPersistentSessions(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Configures all the sessions caches when persistent user sessions feature is enabled.- Parameters:
holder
- TheConfigurationBuilderHolder
where the caches are configured.- Throws:
IllegalStateException
- if an Infinispan cache from the providedcaches
stream is not defined in theholder
. This could indicate a missing or incorrect configuration.
-
configureSessionsCachesForVolatileSessions
public static void configureSessionsCachesForVolatileSessions(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder) Configures all the sessions caches when persistent user sessions feature is enabled.- Parameters:
holder
- TheConfigurationBuilderHolder
where the caches are configured.- Throws:
IllegalStateException
- if an Infinispan cache from the providedcaches
stream is not defined in theholder
. This could indicate a missing or incorrect configuration.
-
maxCountConfigKey
-
getCrlCacheConfig
public static org.infinispan.configuration.cache.ConfigurationBuilder getCrlCacheConfig() -
getRevisionCacheConfig
public static org.infinispan.configuration.cache.ConfigurationBuilder getRevisionCacheConfig(long maxEntries) -
createCacheConfigurationBuilder
public static org.infinispan.configuration.cache.ConfigurationBuilder createCacheConfigurationBuilder()
-