Class CacheFactory
java.lang.Object
com.github.benmanes.caffeine.jcache.CacheFactory
A factory for creating a cache from the configuration.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
A one-shot builder for creating a cache instance.private static final class
private static final class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> CacheProxy <K, V> createCache
(javax.cache.CacheManager cacheManager, String cacheName, javax.cache.configuration.Configuration<K, V> configuration) Returns a fully constructed cache based on the cachestatic boolean
isDefinedExternally
(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
Returns the resolved configuration.static <K,
V> @Nullable CacheProxy <K, V> tryToCreateFromExternalSettings
(javax.cache.CacheManager cacheManager, String cacheName) Returns a newly created cache instance if a definition is found in the external settings file.
-
Constructor Details
-
CacheFactory
private CacheFactory()
-
-
Method Details
-
isDefinedExternally
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, 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 instancecacheName
- 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, 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 instancecacheName
- the name of the cacheconfiguration
- 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.
-