Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbasle committed Aug 12, 2024
1 parent 2eda5d7 commit 4dcdd9a
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*
* @author Stephane Nicoll
* @author Juergen Hoeller
* @author Simon Baslé
* @since 4.1
* @see org.springframework.cache.interceptor.CacheErrorHandler
*/
Expand Down Expand Up @@ -82,6 +83,14 @@ protected Cache.ValueWrapper doGet(Cache cache, Object key) {
}
}

/**
* 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 {
Expand All @@ -101,6 +110,15 @@ protected <T> T doGet(Cache cache, Object key, Callable<T> valueLoader) {
}
}


/**
* 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 {
Expand All @@ -115,6 +133,15 @@ protected CompletableFuture<?> doRetrieve(Cache cache, Object key) {
}
}


/**
* 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);
Expand Down

0 comments on commit 4dcdd9a

Please sign in to comment.