cachingjakarta-eequarkusinvalidationcache-invalidation

How to programmatically invalidate a Quarkus Cache?


I´m running into a problem where using the @CacheInvalidate annotation is not enough anymore.

One method has to erase two different caches, one of them uses two of the given arguments and the other uses all three.

@CacheInvalidate(cacheName = "cache-with-two-identifiers")
@CacheInvalidate(cacheName = "cache-with-three-identifiers")
public void doSomething(@CacheKey String identifier, @CacheKey String anotherIdentifier, String aThirdIdentifier){

}

The @CacheKey annotated arguments are used for the cache with two identifiers, so I cannot annotate the third argument as well, but it would be required to match the keys of the cache-with-three-identifiers.

The only solution I see so far is programmatically clearing the third-arg-cache within the method itself. How would you do that in Quarkus?


Solution

  • There is currently no programmatic caching API for Quarkus. There is already an open issue for it, you can +1 for it and provides feedback: https://github.com/quarkusio/quarkus/issues/8140