Class CacheConfigurator

java.lang.Object
org.keycloak.spi.infinispan.impl.embedded.CacheConfigurator

public final class CacheConfigurator extends Object
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 Type
    Method
    Description
    static void
    applyDefaultConfiguration(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder)
    Applies the default Infinispan cache configuration to the holder, if the cache is not present.
    static void
    checkCachesExist(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder, Stream<String> caches)
    Verifies that all the caches are defined in the holder.
    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
     
    static void
    removeClusteredCaches(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder)
    Removes clustered caches from the holder.
    static void
    validateWorkCacheConfiguration(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder)
    Validates that the "work" cache is present in the holder and has a valid configuration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 - The ConfigurationBuilderHolder 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 the holder, if the cache is not present.

      Each cache may have its own default configuration.

      Parameters:
      holder - The ConfigurationBuilderHolder where the caches will be defined.
    • checkCachesExist

      public static void checkCachesExist(org.infinispan.configuration.parsing.ConfigurationBuilderHolder holder, Stream<String> caches)
      Verifies that all the caches are defined in the holder.
      Parameters:
      holder - The ConfigurationBuilderHolder where the caches are configured.
      caches - The Stream containing the names of the caches to check.
      Throws:
      IllegalStateException - if one or more Infinispan caches from the provided caches stream are not defined in the holder. 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 the holder and has a valid configuration.
      Parameters:
      holder - The ConfigurationBuilderHolder 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 the holder.
      Parameters:
      holder - The ConfigurationBuilderHolder 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 - The ConfigurationBuilderHolder where the caches are configured.
      caches - The Stream containing the names of the caches to configure with a maximum count.
      Throws:
      IllegalStateException - if an Infinispan cache from the provided caches stream is not defined in the holder. 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 - The ConfigurationBuilderHolder where the caches are configured.
      Throws:
      IllegalStateException - if an Infinispan cache from the provided caches stream is not defined in the holder. 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 - The ConfigurationBuilderHolder where the caches are configured.
      Throws:
      IllegalStateException - if an Infinispan cache from the provided caches stream is not defined in the holder. This could indicate a missing or incorrect configuration.
    • maxCountConfigKey

      public static String maxCountConfigKey(String name)
    • 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()