Package io.quarkus.cache
Annotation Interface CacheInvalidate
@InterceptorBinding
@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Repeatable(List.class)
public @interface CacheInvalidate
When a method annotated with
CacheInvalidate is invoked, Quarkus will compute a cache key and use it to try to
remove an existing entry from the cache.
The cache key is computed using the following logic:
- If a
CacheKeyGeneratoris specified with this annotation, then it is used to generate the cache key. The@CacheKeyannotations that might be present on some of the method arguments are ignored. - Otherwise, if the method has no arguments, then the cache key is an instance of
DefaultCacheKeybuilt from the cache name. - Otherwise, if the method has exactly one argument, then that argument is the cache key.
- Otherwise, if the method has multiple arguments but only one annotated with
@CacheKey, then that annotated argument is the cache key. - Otherwise, if the method has multiple arguments annotated with
@CacheKey, then the cache key is an instance ofCompositeCacheKeybuilt from these annotated arguments. - Otherwise, the cache key is an instance of
CompositeCacheKeybuilt from all the method arguments.
If the key does not identify any cache entry, nothing will happen.
This annotation can be combined with multiple other caching annotations on a single method. Caching operations will always
be executed in the same order: CacheInvalidateAll first, then CacheInvalidate and finally
CacheResult.
The underlying caching provider can be chosen and configured in the Quarkus application.properties file.
-
Nested Class Summary
Nested Classes -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends CacheKeyGenerator>TheCacheKeyGeneratorimplementation to use to generate a cache key.
-
Element Details
-
cacheName
String cacheNameThe name of the cache.
-
-
-
keyGenerator
Class<? extends CacheKeyGenerator> keyGeneratorTheCacheKeyGeneratorimplementation to use to generate a cache key.- Default:
- io.quarkus.cache.runtime.UndefinedCacheKeyGenerator.class
-