public abstract class AbstractCacheInvoker extends Object
Cache
operations and using a
configurable CacheErrorHandler
when an exception occurs.CacheErrorHandler
Modifier and Type | Field and Description |
---|---|
protected SingletonSupplier<CacheErrorHandler> |
errorHandler |
Modifier | Constructor and Description |
---|---|
protected |
AbstractCacheInvoker() |
protected |
AbstractCacheInvoker(CacheErrorHandler errorHandler) |
Modifier and Type | Method and Description |
---|---|
protected void |
doClear(Cache cache,
boolean immediate)
Execute
Cache.clear() on the specified Cache and
invoke the error handler if an exception occurs. |
protected void |
doEvict(Cache cache,
Object key,
boolean immediate)
Execute
Cache.evict(Object) /Cache.evictIfPresent(Object) on the
specified Cache and invoke the error handler if an exception occurs. |
protected Cache.ValueWrapper |
doGet(Cache cache,
Object key)
Execute
Cache.get(Object) on the specified Cache and
invoke the error handler if an exception occurs. |
protected void |
doPut(Cache cache,
Object key,
Object result)
Execute
Cache.put(Object, Object) on the specified Cache
and invoke the error handler if an exception occurs. |
CacheErrorHandler |
getErrorHandler()
Return the
CacheErrorHandler to use. |
void |
setErrorHandler(CacheErrorHandler errorHandler)
Set the
CacheErrorHandler instance to use to handle errors
thrown by the cache provider. |
protected SingletonSupplier<CacheErrorHandler> errorHandler
protected AbstractCacheInvoker()
protected AbstractCacheInvoker(CacheErrorHandler errorHandler)
public void setErrorHandler(CacheErrorHandler errorHandler)
CacheErrorHandler
instance to use to handle errors
thrown by the cache provider. By default, a SimpleCacheErrorHandler
is used who throws any exception as is.public CacheErrorHandler getErrorHandler()
CacheErrorHandler
to use.@Nullable protected Cache.ValueWrapper doGet(Cache cache, Object key)
Cache.get(Object)
on the specified Cache
and
invoke the error handler if an exception occurs. Return null
if the handler does not throw any exception, which simulates a cache
miss in case of error.Cache.get(Object)
protected void doPut(Cache cache, Object key, @Nullable Object result)
Cache.put(Object, Object)
on the specified Cache
and invoke the error handler if an exception occurs.protected void doEvict(Cache cache, Object key, boolean immediate)
Cache.evict(Object)
/Cache.evictIfPresent(Object)
on the
specified Cache
and invoke the error handler if an exception occurs.protected void doClear(Cache cache, boolean immediate)
Cache.clear()
on the specified Cache
and
invoke the error handler if an exception occurs.