Class AbstractCacheManager
- All Implemented Interfaces:
InitializingBean, CacheManager
- Direct Known Subclasses:
AbstractTransactionSupportingCacheManager, SimpleCacheManager
CacheManager methods.
Useful for 'static' environments where the backing caches do not change.- Since:
- 3.1
- Author:
- Costin Leau, Juergen Hoeller, Stephane Nicoll
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.protected CachedecorateCache(Cache cache) Decorate the given Cache object if necessary.Get the cache associated with the given name.Get a collection of the cache names known by this manager.getMissingCache(String name) Return a missing cache with the specifiedname, ornullif such a cache does not exist or could not be created on demand.voidInitialize the static configuration of caches.protected abstract Collection<? extends Cache> Load the initial caches for this cache manager.lookupCache(String name) Check for a registered cache of the given name.voidRemove all registered caches from this cache manager if possible, re-creating them on demand.
-
Constructor Details
-
AbstractCacheManager
public AbstractCacheManager()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
initializeCaches
public void initializeCaches()Initialize the static configuration of caches.Triggered on startup through
afterPropertiesSet(); can also be called to re-initialize at runtime.- Since:
- 4.2.2
- See Also:
-
loadCaches
Load the initial caches for this cache manager.Called by
afterPropertiesSet()on startup. The returned collection may be empty but must not benull. -
getCache
Description copied from interface:CacheManagerGet the cache associated with the given name.Note that the cache may be lazily created at runtime if the native provider supports it.
- Specified by:
getCachein interfaceCacheManager- Parameters:
name- the cache identifier (must not benull)- Returns:
- the associated cache, or
nullif such a cache does not exist or could be not created
-
getCacheNames
Description copied from interface:CacheManagerGet a collection of the cache names known by this manager.- Specified by:
getCacheNamesin interfaceCacheManager- Returns:
- the names of all caches known by the cache manager
-
resetCaches
public void resetCaches()Description copied from interface:CacheManagerRemove all registered caches from this cache manager if possible, re-creating them on demand. After this call,CacheManager.getCacheNames()will possibly be empty and the cache provider will have dropped all cache management state.Alternatively, an implementation may perform an equivalent reset on fixed existing cache regions without actually dropping the cache. This behavior will be indicated by
CacheManager.getCacheNames()still exposing a non-empty set of names, whereas the corresponding cache regions will not contain cache entries anymore.The default implementation calls
Cache.clear()on all registered caches, retaining all caches as registered, satisfying the alternative implementation path above. Custom implementations may either drop the actual caches (re-creating them on demand) or perform a more exhaustive reset at the actual cache provider level.- Specified by:
resetCachesin interfaceCacheManager- See Also:
-
lookupCache
Check for a registered cache of the given name. In contrast togetCache(String), this method does not trigger the lazy creation of missing caches viagetMissingCache(String).- Parameters:
name- the cache identifier (must not benull)- Returns:
- the associated Cache instance, or
nullif none found - Since:
- 4.1
- See Also:
-
decorateCache
-
getMissingCache
Return a missing cache with the specifiedname, ornullif such a cache does not exist or could not be created on demand.Caches may be lazily created at runtime if the native provider supports it. If a lookup by name does not yield any result, an
AbstractCacheManagersubclass gets a chance to register such a cache at runtime. The returned cache will be automatically added to this cache manager.- Parameters:
name- the name of the cache to retrieve- Returns:
- the missing cache, or
nullif no such cache exists or could be created on demand - Since:
- 4.1
- See Also:
-