类 AbstractCacheManager
- java.lang.Object
- org.springframework.cache.support.AbstractCacheManager
- 所有已实现的接口:
InitializingBean
,CacheManager
public abstract class AbstractCacheManager extends Object implements CacheManager, InitializingBean
Abstract base class implementing the commonCacheManager
methods. Useful for 'static' environments where the backing caches do not change.- 从以下版本开始:
- 3.1
- 作者:
- Costin Leau, Juergen Hoeller, Stephane Nicoll
构造器概要
构造器 构造器 说明 AbstractCacheManager()
方法概要
所有方法 实例方法 抽象方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected void
addCache(Cache cache)
已过时。as of Spring 4.3, in favor ofgetMissingCache(String)
void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected Cache
decorateCache(Cache cache)
Decorate the given Cache object if necessary.Cache
getCache(String name)
Get the cache associated with the given name.Collection<String>
getCacheNames()
Get a collection of the cache names known by this manager.protected Cache
getMissingCache(String name)
Return a missing cache with the specifiedname
, ornull
if such a cache does not exist or could not be created on demand.void
initializeCaches()
Initialize the static configuration of caches.protected abstract Collection<? extends Cache>
loadCaches()
Load the initial caches for this cache manager.protected Cache
lookupCache(String name)
Check for a registered cache of the given name.
构造器详细资料
AbstractCacheManager
public AbstractCacheManager()
方法详细资料
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
initializeCaches
public void initializeCaches()
Initialize the static configuration of caches.Triggered on startup through
afterPropertiesSet()
; can also be called to re-initialize at runtime.- 从以下版本开始:
- 4.2.2
- 另请参阅:
loadCaches()
loadCaches
protected abstract Collection<? extends Cache> 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
@Nullable public Cache getCache(String name)
从接口复制的说明:CacheManager
Get the cache associated with the given name.Note that the cache may be lazily created at runtime if the native provider supports it.
- 指定者:
getCache
在接口中CacheManager
- 参数:
name
- the cache identifier (must not benull
)- 返回:
- the associated cache, or
null
if such a cache does not exist or could be not created
getCacheNames
public Collection<String> getCacheNames()
从接口复制的说明:CacheManager
Get a collection of the cache names known by this manager.- 指定者:
getCacheNames
在接口中CacheManager
- 返回:
- the names of all caches known by the cache manager
lookupCache
@Nullable protected final Cache lookupCache(String name)
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)
.- 参数:
name
- the cache identifier (must not benull
)- 返回:
- the associated Cache instance, or
null
if none found - 从以下版本开始:
- 4.1
- 另请参阅:
getCache(String)
,getMissingCache(String)
addCache
@Deprecated protected final void addCache(Cache cache)
已过时。as of Spring 4.3, in favor ofgetMissingCache(String)
Dynamically register an additional Cache with this manager.- 参数:
cache
- the Cache to register
decorateCache
protected Cache decorateCache(Cache cache)
Decorate the given Cache object if necessary.- 参数:
cache
- the Cache object to be added to this CacheManager- 返回:
- the decorated Cache object to be used instead, or simply the passed-in Cache object by default
getMissingCache
@Nullable protected Cache getMissingCache(String name)
Return a missing cache with the specifiedname
, ornull
if 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
AbstractCacheManager
subclass gets a chance to register such a cache at runtime. The returned cache will be automatically added to this cache manager.- 参数:
name
- the name of the cache to retrieve- 返回:
- the missing cache, or
null
if no such cache exists or could be created on demand - 从以下版本开始:
- 4.1
- 另请参阅:
getCache(String)