parent
2eda5d7a2a
commit
4dcdd9a224
|
@ -30,6 +30,7 @@ import org.springframework.util.function.SingletonSupplier;
|
|||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Juergen Hoeller
|
||||
* @author Simon Baslé
|
||||
* @since 4.1
|
||||
* @see org.springframework.cache.interceptor.CacheErrorHandler
|
||||
*/
|
||||
|
@ -82,6 +83,14 @@ public abstract class AbstractCacheInvoker {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute {@link Cache#get(Object, Callable)} on the specified
|
||||
* {@link Cache} and invoke the error handler if an exception occurs.
|
||||
* Invokes the {@code valueLoader} if the handler does not throw any
|
||||
* exception, which simulates a cache read-through in case of error.
|
||||
* @since 6.2
|
||||
* @see Cache#get(Object, Callable)
|
||||
*/
|
||||
@Nullable
|
||||
protected <T> T doGet(Cache cache, Object key, Callable<T> valueLoader) {
|
||||
try {
|
||||
|
@ -101,6 +110,15 @@ public abstract class AbstractCacheInvoker {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute {@link Cache#retrieve(Object)} on the specified {@link Cache}
|
||||
* and invoke the error handler if an exception occurs.
|
||||
* Returns {@code null} if the handler does not throw any exception, which
|
||||
* simulates a cache miss in case of error.
|
||||
* @since 6.2
|
||||
* @see Cache#retrieve(Object)
|
||||
*/
|
||||
@Nullable
|
||||
protected CompletableFuture<?> doRetrieve(Cache cache, Object key) {
|
||||
try {
|
||||
|
@ -115,6 +133,15 @@ public abstract class AbstractCacheInvoker {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute {@link Cache#retrieve(Object, Supplier)} on the specified
|
||||
* {@link Cache} and invoke the error handler if an exception occurs.
|
||||
* Invokes the {@code valueLoader} if the handler does not throw any
|
||||
* exception, which simulates a cache read-through in case of error.
|
||||
* @since 6.2
|
||||
* @see Cache#retrieve(Object, Supplier)
|
||||
*/
|
||||
protected <T> CompletableFuture<T> doRetrieve(Cache cache, Object key, Supplier<CompletableFuture<T>> valueLoader) {
|
||||
try {
|
||||
return cache.retrieve(key, valueLoader);
|
||||
|
|
Loading…
Reference in New Issue