Created
March 9, 2021 15:10
-
-
Save mihaita-tinta/791f8d43e1627b6774c7da86d4f22843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Object invoke(MethodInvocation invocation) throws Throwable { | |
//... | |
CompletableFutureCacheableEvict evictAnnotation = invocation.getMethod().getAnnotation(CompletableFutureCacheableEvict.class); | |
//... | |
return callMethod(invocation) | |
.thenApply(newValue -> { | |
getCache(cacheName) | |
.put(cacheKey, newValue); | |
if (evictAnnotation != null) { | |
String cacheEvictName = evictAnnotation.value(); | |
Object evictKey = extractCacheKey(evictAnnotation.keySpel(), invocation); | |
getCache(cacheEvictName) | |
.evictIfPresent(evictKey); | |
} | |
return newValue; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment