Package de.xima.fc.api.cache
Class GlobalCacheManager
java.lang.Object
de.xima.fc.api.cache.GlobalCacheManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.ehcache.CacheManagerGets the cacheManagerstatic <K,V> org.ehcache.Cache<K, V> getInstanceCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K, V>> configBuilder) Returns the cache with the given name.static voidinit()static <K,V> void initCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K, V>> configBuilder) static voidreinit()Reinitialize cache after configuration changestatic <K,V> org.ehcache.Cache<K, V> reinitCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K, V>> configBuilder) Reinitializes the cache with the given name.static voidshutdown()Removes all EH caches.static voidshutdownCache(String alias) Shuts down the given with the given name.
-
Constructor Details
-
GlobalCacheManager
public GlobalCacheManager()
-
-
Method Details
-
init
public static void init() -
initCache
-
getInstanceCache
public static <K,V> org.ehcache.Cache<K,V> getInstanceCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K, V>> configBuilder) Returns the cache with the given name. When the cache does not exist, a new cache is created.- Type Parameters:
K- Type of the cache key.V- Type of the cached values.- Parameters:
alias- Name of the cache.keyType- Type of the cache key.valueType- Type of the cached values.configBuilder- Supplier that is called when no cache exists and a new cache needs to be created. It should return the configuration for the new cache.- Returns:
- The newly created cache,
nullwhen the cache could not be created.
-
reinitCache
public static <K,V> org.ehcache.Cache<K,V> reinitCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K, V>> configBuilder) Reinitializes the cache with the given name. Shuts down the cache if present and recreates it.- Type Parameters:
K- Type of the cache key.V- Type of the cached values.- Parameters:
alias- Name of the cache.keyType- Type of the cache key.valueType- Type of the cached values.configBuilder- Supplier that should return the configuration for the new cache.- Returns:
- The newly created cache,
nullwhen the cache could not be created.
-
shutdownCache
Shuts down the given with the given name.- Parameters:
alias- Name of the cache to shut down.
-
getInstance
public static org.ehcache.CacheManager getInstance()Gets the cacheManager- Returns:
- the cacheManager
-
shutdown
public static void shutdown()Removes all EH caches. -
reinit
public static void reinit()Reinitialize cache after configuration change
-