Package org.apache.shiro.cache
Class AbstractCacheManager
java.lang.Object
org.apache.shiro.cache.AbstractCacheManager
- All Implemented Interfaces:
CacheManager,org.apache.shiro.lang.util.Destroyable
- Direct Known Subclasses:
MemoryConstrainedCacheManager
public abstract class AbstractCacheManager
extends Object
implements CacheManager, org.apache.shiro.lang.util.Destroyable
Very simple abstract
CacheManager implementation that retains all created Cache instances in
an in-memory ConcurrentMap. Cache instance creation is left to subclasses via
the createCache method implementation.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefault no-arg constructor that instantiates an internal name-to-cacheConcurrentMap. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <K,V> Cache <K, V> createCache(String name) Creates a newCacheinstance associated with the specifiedname.voiddestroy()Cleanup method that firstdestroysall of it's managed caches and thenclearsout the internally referenced cache map.<K,V> Cache <K, V> Returns the cache with the specifiedname.toString()
-
Constructor Details
-
AbstractCacheManager
public AbstractCacheManager()Default no-arg constructor that instantiates an internal name-to-cacheConcurrentMap.
-
-
Method Details
-
getCache
Returns the cache with the specifiedname. If the cache instance does not yet exist, it will be lazily created, retained for further access, and then returned.- Specified by:
getCachein interfaceCacheManager- Parameters:
name- the name of the cache to acquire.- Returns:
- the cache with the specified
name. - Throws:
IllegalArgumentException- if thenameargument isnullor does not contain text.CacheException- if there is a problem lazily creating aCacheinstance.
-
createCache
Creates a newCacheinstance associated with the specifiedname.- Parameters:
name- the name of the cache to create- Returns:
- a new
Cacheinstance associated with the specifiedname. - Throws:
CacheException- if theCacheinstance cannot be created.
-
destroy
Cleanup method that firstdestroysall of it's managed caches and thenclearsout the internally referenced cache map.- Specified by:
destroyin interfaceorg.apache.shiro.lang.util.Destroyable- Throws:
Exception- if any of the managed caches can't destroy properly.
-
toString
-