Package org.apache.shiro.cache
Class AbstractCacheManager
- java.lang.Object
-
- org.apache.shiro.cache.AbstractCacheManager
-
- All Implemented Interfaces:
CacheManager,org.apache.shiro.util.Destroyable
- Direct Known Subclasses:
MemoryConstrainedCacheManager
public abstract class AbstractCacheManager extends Object implements CacheManager, org.apache.shiro.util.Destroyable
Very simple abstractCacheManagerimplementation that retains all createdCacheinstances in an in-memoryConcurrentMap.Cacheinstance creation is left to subclasses via thecreateCachemethod implementation.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description AbstractCacheManager()Default no-arg constructor that instantiates an internal name-to-cacheConcurrentMap.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract CachecreateCache(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>getCache(String name)Returns the cache with the specifiedname.StringtoString()
-
-
-
Method Detail
-
getCache
public <K,V> Cache<K,V> getCache(String name) throws IllegalArgumentException, CacheException
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
protected abstract Cache createCache(String name) throws CacheException
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
public void destroy() throws ExceptionCleanup method that firstdestroysall of it's managed caches and thenclearsout the internally referenced cache map.- Specified by:
destroyin interfaceorg.apache.shiro.util.Destroyable- Throws:
Exception- if any of the managed caches can't destroy properly.
-
-