Class AbstractCacheInvoker
java.lang.Object
org.springframework.cache.interceptor.AbstractCacheInvoker
- Direct Known Subclasses:
CacheAspectSupport
,JCacheAspectSupport
A base component for invoking
Cache
operations and using a
configurable CacheErrorHandler
when an exception occurs.- Since:
- 4.1
- Author:
- Stephane Nicoll, Juergen Hoeller, Simon Baslé
- See Also:
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
AbstractCacheInvoker
(CacheErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
ExecuteCache.clear()
on the specifiedCache
and invoke the error handler if an exception occurs.protected void
ExecuteCache.evict(Object)
/Cache.evictIfPresent(Object)
on the specifiedCache
and invoke the error handler if an exception occurs.protected @Nullable Cache.ValueWrapper
ExecuteCache.get(Object)
on the specifiedCache
and invoke the error handler if an exception occurs.protected <T> @Nullable T
ExecuteCache.get(Object, Callable)
on the specifiedCache
and invoke the error handler if an exception occurs.protected void
ExecuteCache.put(Object, Object)
on the specifiedCache
and invoke the error handler if an exception occurs.protected @Nullable CompletableFuture<?>
doRetrieve
(Cache cache, Object key) ExecuteCache.retrieve(Object)
on the specifiedCache
and invoke the error handler if an exception occurs.protected <T> CompletableFuture<T>
doRetrieve
(Cache cache, Object key, Supplier<CompletableFuture<T>> valueLoader) ExecuteCache.retrieve(Object, Supplier)
on the specifiedCache
and invoke the error handler if an exception occurs.Return theCacheErrorHandler
to use.void
setErrorHandler
(CacheErrorHandler errorHandler) Set theCacheErrorHandler
instance to use to handle errors thrown by the cache provider.
-
Field Details
-
errorHandler
-
-
Constructor Details
-
AbstractCacheInvoker
protected AbstractCacheInvoker() -
AbstractCacheInvoker
-
-
Method Details
-
setErrorHandler
Set theCacheErrorHandler
instance to use to handle errors thrown by the cache provider. By default, aSimpleCacheErrorHandler
is used who throws any exception as is. -
getErrorHandler
Return theCacheErrorHandler
to use. -
doGet
ExecuteCache.get(Object)
on the specifiedCache
and invoke the error handler if an exception occurs. Returnnull
if the handler does not throw any exception, which simulates a cache miss in case of error.- See Also:
-
doGet
ExecuteCache.get(Object, Callable)
on the specifiedCache
and invoke the error handler if an exception occurs. Invokes thevalueLoader
if the handler does not throw any exception, which simulates a cache read-through in case of error.- Since:
- 6.2
- See Also:
-
doRetrieve
ExecuteCache.retrieve(Object)
on the specifiedCache
and invoke the error handler if an exception occurs. Returnsnull
if the handler does not throw any exception, which simulates a cache miss in case of error.- Since:
- 6.2
- See Also:
-
doRetrieve
protected <T> CompletableFuture<T> doRetrieve(Cache cache, Object key, Supplier<CompletableFuture<T>> valueLoader) ExecuteCache.retrieve(Object, Supplier)
on the specifiedCache
and invoke the error handler if an exception occurs. Invokes thevalueLoader
if the handler does not throw any exception, which simulates a cache read-through in case of error.- Since:
- 6.2
- See Also:
-
doPut
ExecuteCache.put(Object, Object)
on the specifiedCache
and invoke the error handler if an exception occurs. -
doEvict
ExecuteCache.evict(Object)
/Cache.evictIfPresent(Object)
on the specifiedCache
and invoke the error handler if an exception occurs. -
doClear
ExecuteCache.clear()
on the specifiedCache
and invoke the error handler if an exception occurs.
-