Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mihaita-tinta/791f8d43e1627b6774c7da86d4f22843 to your computer and use it in GitHub Desktop.
Save mihaita-tinta/791f8d43e1627b6774c7da86d4f22843 to your computer and use it in GitHub Desktop.
@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