Package de.xima.fc.api.cache
Class GlobalCacheManager
- java.lang.Object
-
- de.xima.fc.api.cache.GlobalCacheManager
-
public class GlobalCacheManager extends Object
-
-
Constructor Summary
Constructors Constructor Description GlobalCacheManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.ehcache.CacheManager
getInstance()
Gets 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 void
init()
static <K,V>
voidinitCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K,V>> configBuilder)
static void
reinit()
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 void
shutdown()
Removes all EH caches.static void
shutdownCache(String alias)
Shuts down the given with the given name.
-
-
-
Method Detail
-
init
public static void init()
-
initCache
public static <K,V> void initCache(String alias, Class<K> keyType, Class<V> valueType, Supplier<org.ehcache.config.CacheConfiguration<K,V>> configBuilder)
-
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,
null
when 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,
null
when the cache could not be created.
-
shutdownCache
public static void shutdownCache(String alias)
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
-
-