30
30
*
31
31
* @author Stephane Nicoll
32
32
* @author Juergen Hoeller
33
+ * @author Simon Baslé
33
34
* @since 4.1
34
35
* @see org.springframework.cache.interceptor.CacheErrorHandler
35
36
*/
@@ -82,6 +83,14 @@ protected Cache.ValueWrapper doGet(Cache cache, Object key) {
82
83
}
83
84
}
84
85
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
+ */
85
94
@ Nullable
86
95
protected <T > T doGet (Cache cache , Object key , Callable <T > valueLoader ) {
87
96
try {
@@ -101,6 +110,15 @@ protected <T> T doGet(Cache cache, Object key, Callable<T> valueLoader) {
101
110
}
102
111
}
103
112
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
+ */
104
122
@ Nullable
105
123
protected CompletableFuture <?> doRetrieve (Cache cache , Object key ) {
106
124
try {
@@ -115,6 +133,15 @@ protected CompletableFuture<?> doRetrieve(Cache cache, Object key) {
115
133
}
116
134
}
117
135
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
+ */
118
145
protected <T > CompletableFuture <T > doRetrieve (Cache cache , Object key , Supplier <CompletableFuture <T >> valueLoader ) {
119
146
try {
120
147
return cache .retrieve (key , valueLoader );
0 commit comments