Class CacheFactory


  • final class CacheFactory
    extends java.lang.Object
    A factory for creating a cache from the configuration.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CacheFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      CacheProxy<K,​V>
      createCache​(javax.cache.CacheManager cacheManager, java.lang.String cacheName, javax.cache.configuration.Configuration<K,​V> configuration)
      Returns a fully constructed cache based on the cache
      static boolean isDefinedExternally​(java.lang.String cacheName)
      Returns a if the cache definition is found in the external settings file.
      private static <K,​V>
      CaffeineConfiguration<K,​V>
      resolveConfigurationFor​(javax.cache.configuration.Configuration<K,​V> configuration)
      Copies the configuration and overlays it on top of the default settings.
      private static com.typesafe.config.Config rootConfig()
      Returns the resolved configuration.
      static <K,​V>
      @Nullable CacheProxy<K,​V>
      tryToCreateFromExternalSettings​(javax.cache.CacheManager cacheManager, java.lang.String cacheName)
      Returns a newly created cache instance if a definition is found in the external settings file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheFactory

        private CacheFactory()
    • Method Detail

      • isDefinedExternally

        public static boolean isDefinedExternally​(java.lang.String cacheName)
        Returns a if the cache definition is found in the external settings file.
        Parameters:
        cacheName - the name of the cache
        Returns:
        true if a definition exists
      • tryToCreateFromExternalSettings

        public static <K,​V> @Nullable CacheProxy<K,​V> tryToCreateFromExternalSettings​(javax.cache.CacheManager cacheManager,
                                                                                                  java.lang.String cacheName)
        Returns a newly created cache instance if a definition is found in the external settings file.
        Parameters:
        cacheManager - the owner of the cache instance
        cacheName - the name of the cache
        Returns:
        a new cache instance or null if the named cache is not defined in the settings file
      • createCache

        public static <K,​V> CacheProxy<K,​V> createCache​(javax.cache.CacheManager cacheManager,
                                                                    java.lang.String cacheName,
                                                                    javax.cache.configuration.Configuration<K,​V> configuration)
        Returns a fully constructed cache based on the cache
        Parameters:
        cacheManager - the owner of the cache instance
        cacheName - the name of the cache
        configuration - the full cache definition
        Returns:
        a newly constructed cache instance
      • rootConfig

        private static com.typesafe.config.Config rootConfig()
        Returns the resolved configuration.
      • resolveConfigurationFor

        private static <K,​V> CaffeineConfiguration<K,​V> resolveConfigurationFor​(javax.cache.configuration.Configuration<K,​V> configuration)
        Copies the configuration and overlays it on top of the default settings.