Skip to content

Commit 4dcdd9a

Browse files
committed
Polishing
See gh-21590
1 parent 2eda5d7 commit 4dcdd9a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheInvoker.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*
3131
* @author Stephane Nicoll
3232
* @author Juergen Hoeller
33+
* @author Simon Baslé
3334
* @since 4.1
3435
* @see org.springframework.cache.interceptor.CacheErrorHandler
3536
*/
@@ -82,6 +83,14 @@ protected Cache.ValueWrapper doGet(Cache cache, Object key) {
8283
}
8384
}
8485

86+
/**
87+
* Execute {@link Cache#get(Object, Callable)} on the specified
88+
* {@link Cache} and invoke the error handler if an exception occurs.
89+
* Invokes the {@code valueLoader} if the handler does not throw any
90+
* exception, which simulates a cache read-through in case of error.
91+
* @since 6.2
92+
* @see Cache#get(Object, Callable)
93+
*/
8594
@Nullable
8695
protected <T> T doGet(Cache cache, Object key, Callable<T> valueLoader) {
8796
try {
@@ -101,6 +110,15 @@ protected <T> T doGet(Cache cache, Object key, Callable<T> valueLoader) {
101110
}
102111
}
103112

113+
114+
/**
115+
* Execute {@link Cache#retrieve(Object)} on the specified {@link Cache}
116+
* and invoke the error handler if an exception occurs.
117+
* Returns {@code null} if the handler does not throw any exception, which
118+
* simulates a cache miss in case of error.
119+
* @since 6.2
120+
* @see Cache#retrieve(Object)
121+
*/
104122
@Nullable
105123
protected CompletableFuture<?> doRetrieve(Cache cache, Object key) {
106124
try {
@@ -115,6 +133,15 @@ protected CompletableFuture<?> doRetrieve(Cache cache, Object key) {
115133
}
116134
}
117135

136+
137+
/**
138+
* Execute {@link Cache#retrieve(Object, Supplier)} on the specified
139+
* {@link Cache} and invoke the error handler if an exception occurs.
140+
* Invokes the {@code valueLoader} if the handler does not throw any
141+
* exception, which simulates a cache read-through in case of error.
142+
* @since 6.2
143+
* @see Cache#retrieve(Object, Supplier)
144+
*/
118145
protected <T> CompletableFuture<T> doRetrieve(Cache cache, Object key, Supplier<CompletableFuture<T>> valueLoader) {
119146
try {
120147
return cache.retrieve(key, valueLoader);

0 commit comments

Comments
 (0)