Add caching annotation support for CompletableFuture and reactive return values
Includes CompletableFuture-based retrieve operations on Spring's Cache interface.
Includes support for retrieve operations on CaffeineCache and ConcurrentMapCache.
Includes async cache mode option on CaffeineCacheManager.
Closes gh-17559
Closes gh-17920
Closes gh-30122
@ -43,6 +50,9 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
@@ -43,6 +50,9 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
@ -72,17 +82,51 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
@@ -72,17 +82,51 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
"No Caffeine AsyncCache available: set CaffeineCacheManager.setAsyncCacheMode(true)");
returnthis.asyncCache;
}
@SuppressWarnings("unchecked")
@Override
@Nullable
@ -90,6 +134,22 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
@@ -90,6 +134,22 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
@ -110,7 +122,7 @@ public class CaffeineCacheManager implements CacheManager {
@@ -110,7 +122,7 @@ public class CaffeineCacheManager implements CacheManager {
Assert.notNull(caffeine,"Caffeine must not be null");
@ -121,7 +133,7 @@ public class CaffeineCacheManager implements CacheManager {
@@ -121,7 +133,7 @@ public class CaffeineCacheManager implements CacheManager {
@ -132,7 +144,7 @@ public class CaffeineCacheManager implements CacheManager {
@@ -132,7 +144,7 @@ public class CaffeineCacheManager implements CacheManager {
@ -149,7 +161,7 @@ public class CaffeineCacheManager implements CacheManager {
@@ -149,7 +161,7 @@ public class CaffeineCacheManager implements CacheManager {
@ -159,6 +171,45 @@ public class CaffeineCacheManager implements CacheManager {
@@ -159,6 +171,45 @@ public class CaffeineCacheManager implements CacheManager {
@ -211,13 +262,34 @@ public class CaffeineCacheManager implements CacheManager {
@@ -211,13 +262,34 @@ public class CaffeineCacheManager implements CacheManager {
@ -225,13 +297,27 @@ public class CaffeineCacheManager implements CacheManager {
@@ -225,13 +297,27 @@ public class CaffeineCacheManager implements CacheManager {
@ -244,7 +330,8 @@ public class CaffeineCacheManager implements CacheManager {
@@ -244,7 +330,8 @@ public class CaffeineCacheManager implements CacheManager {
@ -255,7 +342,29 @@ public class CaffeineCacheManager implements CacheManager {
@@ -255,7 +342,29 @@ public class CaffeineCacheManager implements CacheManager {
@ -91,6 +93,17 @@ public class TransactionAwareCacheDecorator implements Cache {
@@ -91,6 +93,17 @@ public class TransactionAwareCacheDecorator implements Cache {
@ -149,6 +156,20 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@@ -149,6 +156,20 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@ -103,6 +116,11 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -103,6 +116,11 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -371,41 +389,25 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -371,41 +389,25 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -414,8 +416,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -414,8 +416,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
cacheValue=unwrapReturnValue(returnValue);
}
// Collect puts from any @Cacheable miss, if no cached item is found
@ -425,29 +427,52 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -425,29 +427,52 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
// Process any collected put requests, either from @CachePut or a @Cacheable miss
// No caching required, just call the underlying method
returninvokeOperation(invoker);
}
returnresult;
}
@Nullable
@ -467,7 +492,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -467,7 +492,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -482,32 +507,55 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -482,32 +507,55 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -520,19 +568,21 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -520,19 +568,21 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
logger.trace("Cache entry for key '"+key+"' found in cache(s) "+context.getCacheNames());
}
returncached;
}
else{
@ -547,9 +597,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -547,9 +597,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -564,15 +614,18 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -564,15 +614,18 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -625,13 +678,13 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -625,13 +678,13 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -641,13 +694,13 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -641,13 +694,13 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
thrownewIllegalStateException(
"A sync=true operation cannot be combined with other cache operations on '"+method+"'");
}
if(cacheOperationContexts.size()>1){
if(cacheableContexts.size()>1){
thrownewIllegalStateException(
"Only one sync=true operation is allowed on '"+method+"'");
"A sync=true operation is restricted to a single cache on '"+operation+"'");
}
@ -720,7 +773,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -720,7 +773,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -808,8 +861,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -808,8 +861,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -818,25 +871,6 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -818,25 +871,6 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -876,12 +910,168 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -876,12 +910,168 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker