Class CacheFactory
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.CacheFactory
-
final class CacheFactory extends java.lang.Object
A factory for creating a cache from the configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CacheFactory.Builder<K,V>
A one-shot builder for creating a cache instance.private static class
CacheFactory.ExpirableToExpiry<K,V>
private static class
CacheFactory.ExpiryAdapter<K,V>
-
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 cachestatic 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.
-
-
-
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 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, 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 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.
-
-