Annotation Type CacheResult
-
@InterceptorBinding @Target({TYPE,METHOD}) @Retention(RUNTIME) public @interface CacheResult
When a method annotated withCacheResultis invoked, Quarkus will use the method argument as key and use it to check in the Infinispan cache if the method has been already invoked. If a value is found in the cache, it is returned and the annotated method is never actually executed. If no value is found, the annotated method is invoked and the returned value is stored in the cache using the computed key.A method annotated with
CacheResultis protected by a lock on cache miss mechanism. If several concurrent invocations try to retrieve a cache value from the same missing key, the method will only be invoked once. The first concurrent invocation will trigger the method invocation while the subsequent concurrent invocations will wait for the end of the method invocation to get the cached result. ThelockTimeoutparameter can be used to interrupt the lock after a given delay. The lock timeout is disabled by default, meaning the lock is never interrupted. See the parameter Javadoc for more details.This annotation cannot be used on a method returning
void. It can be combined withCacheInvalidateandCacheInvalidateAllannotations on a single method. Caching operations will always be executed in the same order:CacheInvalidateAllfirst, thenCacheInvalidateand finallyCacheResult.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description longlockTimeoutDelay in milliseconds before the lock on cache miss is interrupted.
-
-
-
Element Detail
-
cacheName
String cacheName
The name of the cache.
-
-
-
lockTimeout
long lockTimeout
Delay in milliseconds before the lock on cache miss is interrupted. If such interruption happens, the cached method will be invoked and its result will be returned without being cached. A value of0(which is the default one) means that the lock timeout is disabled.- Default:
- 0L
-
-