类 AbstractCacheInvoker
- java.lang.Object
- org.springframework.cache.interceptor.AbstractCacheInvoker
public abstract class AbstractCacheInvoker extends Object
A base component for invokingCacheoperations and using a configurableCacheErrorHandlerwhen an exception occurs.- 从以下版本开始:
- 4.1
- 作者:
- Stephane Nicoll, Juergen Hoeller
- 另请参阅:
CacheErrorHandler
字段概要
字段 修饰符和类型 字段 说明 protected SingletonSupplier<CacheErrorHandler>errorHandler
构造器概要
构造器 限定符 构造器 说明 protectedAbstractCacheInvoker()protectedAbstractCacheInvoker(CacheErrorHandler errorHandler)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected voiddoClear(Cache cache, boolean immediate)ExecuteCache.clear()on the specifiedCacheand invoke the error handler if an exception occurs.protected voiddoEvict(Cache cache, Object key, boolean immediate)ExecuteCache.evict(Object)/Cache.evictIfPresent(Object)on the specifiedCacheand invoke the error handler if an exception occurs.protected Cache.ValueWrapperdoGet(Cache cache, Object key)ExecuteCache.get(Object)on the specifiedCacheand invoke the error handler if an exception occurs.protected voiddoPut(Cache cache, Object key, Object result)ExecuteCache.put(Object, Object)on the specifiedCacheand invoke the error handler if an exception occurs.CacheErrorHandlergetErrorHandler()Return theCacheErrorHandlerto use.voidsetErrorHandler(CacheErrorHandler errorHandler)Set theCacheErrorHandlerinstance to use to handle errors thrown by the cache provider.
字段详细资料
errorHandler
protected SingletonSupplier<CacheErrorHandler> errorHandler
构造器详细资料
AbstractCacheInvoker
protected AbstractCacheInvoker()
AbstractCacheInvoker
protected AbstractCacheInvoker(CacheErrorHandler errorHandler)
方法详细资料
setErrorHandler
public void setErrorHandler(CacheErrorHandler errorHandler)
Set theCacheErrorHandlerinstance to use to handle errors thrown by the cache provider. By default, aSimpleCacheErrorHandleris used who throws any exception as is.
getErrorHandler
public CacheErrorHandler getErrorHandler()
Return theCacheErrorHandlerto use.
doGet
@Nullable protected Cache.ValueWrapper doGet(Cache cache, Object key)
ExecuteCache.get(Object)on the specifiedCacheand invoke the error handler if an exception occurs. Returnnullif the handler does not throw any exception, which simulates a cache miss in case of error.- 另请参阅:
Cache.get(Object)
doPut
protected void doPut(Cache cache, Object key, @Nullable Object result)
ExecuteCache.put(Object, Object)on the specifiedCacheand invoke the error handler if an exception occurs.
doEvict
protected void doEvict(Cache cache, Object key, boolean immediate)
ExecuteCache.evict(Object)/Cache.evictIfPresent(Object)on the specifiedCacheand invoke the error handler if an exception occurs.
doClear
protected void doClear(Cache cache, boolean immediate)
ExecuteCache.clear()on the specifiedCacheand invoke the error handler if an exception occurs.