Package org.ehcache
Interface CacheManager
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Subinterfaces:
PersistentCacheManager
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Transitions thisCacheManagertoUNINITIALIZED.<K,V> Cache<K, V> createCache(String alias, Builder<? extends CacheConfiguration<K, V>> configBuilder) Creates aCachein thisCacheManageraccording to the specifiedCacheConfigurationprovided through aBuilder.<K,V> Cache<K, V> createCache(String alias, CacheConfiguration<K, V> config) <K,V> Cache<K, V> Retrieves theCacheassociated with the given alias, if one is known.Returns the currentConfigurationused by thisCacheManager.Returns the currentStatusof thisCacheManager.voidinit()Transitions thisCacheManagertoAVAILABLE.voidremoveCache(String alias) Removes theCacheassociated with the alias provided, if one is known.
-
Method Details
-
createCache
Creates aCachein thisCacheManageraccording to the specifiedCacheConfiguration.The returned
Cachewill be in statusAVAILABLE.- Type Parameters:
K- the key type for the cacheV- the value type for the cache- Parameters:
alias- the alias under which the cache will be createdconfig- the configuration of the cache to create- Returns:
- the created and available
Cache - Throws:
IllegalArgumentException- if there is already a cache registered with the given aliasIllegalStateException- if the cache creation fails
-
createCache
<K,V> Cache<K,V> createCache(String alias, Builder<? extends CacheConfiguration<K, V>> configBuilder) Creates aCachein thisCacheManageraccording to the specifiedCacheConfigurationprovided through aBuilder.The returned
Cachewill be in statusAVAILABLE.- Type Parameters:
K- the key type for the cacheV- the value type for the cache- Parameters:
alias- the alias under which the cache will be createdconfigBuilder- the builder for the configuration of the cache to create- Returns:
- the created and available
Cache - Throws:
IllegalArgumentException- if there is already a cache registered with the given aliasIllegalStateException- if the cache creation fails
-
getCache
Retrieves theCacheassociated with the given alias, if one is known.- Type Parameters:
K- the key type for the cacheV- the value type for the cache- Parameters:
alias- the alias under which to look theCacheupkeyType- theCachekey classvalueType- theCachevalue class- Returns:
- the
Cacheassociated with the given alias,nullif no such cache exists - Throws:
IllegalArgumentException- if the keyType or valueType do not match the ones with which theCachewas created
-
removeCache
Removes theCacheassociated with the alias provided, if one is known.When the cache is removed, it will release all resources it used.
- Parameters:
alias- the alias for which to remove theCache
-
init
Transitions thisCacheManagertoAVAILABLE.This will start all
Services managed by thisCacheManager, as well as initializing allCaches registered with it.If an error occurs before the
CacheManagerisAVAILABLE, it will revert toUNINITIALIZEDattempting to close all services it had already started.- Throws:
IllegalStateException- if theCacheManageris notUNINITIALIZEDStateTransitionException- if theCacheManagercould not be madeAVAILABLE
-
close
Transitions thisCacheManagertoUNINITIALIZED.This will close all
Caches known to thisCacheManagerand stop allServices managed by thisCacheManager.Failure to close any
Cacheor to stop anyServicewill not prevent others from being closed or stopped.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
StateTransitionException- if theCacheManagercould not reachUNINITIALIZEDcleanlyIllegalStateException- if theCacheManageris notAVAILABLE
-
getStatus
Status getStatus()Returns the currentStatusof thisCacheManager.- Returns:
- the current
Status
-
getRuntimeConfiguration
Configuration getRuntimeConfiguration()Returns the currentConfigurationused by thisCacheManager.- Returns:
- the configuration instance backing this
CacheManager
-