Package io.micronaut.cache.annotation
Annotation Interface CachePut
@Target({METHOD,TYPE})
@Retention(RUNTIME)
@Inherited
@Documented
@CacheConfig
@CacheAnnotation
@Repeatable(PutOperations.class)
public @interface CachePut
An annotation that can be applied at the type or method level to indicate that the annotated operation should
cause the return value to be cached within the given cache name. Unlike Cacheable
this annotation will never
skip the original invocation.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Whether theCachePut
operation should be performed asynchronously and not block the returning valueString[]
Alias forCacheConfig.cacheNames()
.Evaluated expression that can be used to indicate whether the value should be cached.Class<? extends CacheKeyGenerator>
Alias forCacheConfig.keyGenerator()
.String[]
Limit the automaticCacheKeyGenerator
to the given parameter names.String[]
Alias forCacheConfig.cacheNames()
.
-
Element Details
-
value
Alias forCacheConfig.cacheNames()
.- Returns:
- The cache names
- Default:
- {}
-
cacheNames
Alias forCacheConfig.cacheNames()
.- Returns:
- The cache names
- Default:
- {}
-
keyGenerator
@AliasFor(annotation=CacheConfig.class, member="keyGenerator") Class<? extends CacheKeyGenerator> keyGeneratorAlias forCacheConfig.keyGenerator()
.- Returns:
- The key generator class
- Default:
- io.micronaut.cache.interceptor.DefaultCacheKeyGenerator.class
-
parameters
String[] parametersLimit the automaticCacheKeyGenerator
to the given parameter names. Mutually exclusive withkeyGenerator()
- Returns:
- The parameter names that make up the key.
- Default:
- {}
-
async
boolean asyncWhether the
CachePut
operation should be performed asynchronously and not block the returning valueThe value if
async
impacts behaviour in the following ways:- For blocking return types when the value is
false
the method will not return until the value has been written and any cache write errors will be propagated back to the client. - For blocking return types when the value is
true
the method will return prior to cache writes occurring and errors will be logged via theAsyncCacheErrorHandler
. - When the return type is a
CompletableFuture
and the value isfalse
the future will not complete until theCachePut
operation is complete. - When the return type is a
CompletableFuture
and the value istrue
the future will complete prior to anyCachePut
operations completing and the operations will be executing asynchronously with errors logged byAsyncCacheErrorHandler
.
- Returns:
- True if cache writes should be done asynchronously
- Default:
- false
- For blocking return types when the value is
-
condition
String conditionEvaluated expression that can be used to indicate whether the value should be cached. Will be evaluated each time the method is called, and if the condition evaluates to false the cache will not be used.- Returns:
- The condition
- Since:
- 4.2.0
- See Also:
- Default:
- ""
-