Package io.micronaut.cache.annotation
Annotation Type CachePut
-
@Target({METHOD,TYPE}) @Retention(RUNTIME) @Inherited @Documented @CacheConfig @CacheAnnotation @Repeatable(PutOperations.class) public @interface CachePutAn 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
Cacheablethis annotation will never skip the original invocation.- Since:
- 1.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanasyncWhether theCachePutoperation should be performed asynchronously and not block the returning valuejava.lang.String[]cacheNamesAlias forCacheConfig.cacheNames().java.lang.Class<? extends CacheKeyGenerator>keyGeneratorAlias forCacheConfig.keyGenerator().java.lang.String[]parametersLimit the automaticCacheKeyGeneratorto the given parameter names.java.lang.String[]valueAlias forCacheConfig.cacheNames().
-
-
-
Element Detail
-
value
@AliasFor(member="cacheNames") java.lang.String[] value
Alias forCacheConfig.cacheNames().- Returns:
- The cache names
- Default:
- {}
-
-
-
cacheNames
@AliasFor(annotation=CacheConfig.class, member="cacheNames") java.lang.String[] cacheNames
Alias forCacheConfig.cacheNames().- Returns:
- The cache names
- Default:
- {}
-
-
-
keyGenerator
@AliasFor(annotation=CacheConfig.class, member="keyGenerator") java.lang.Class<? extends CacheKeyGenerator> keyGenerator
Alias forCacheConfig.keyGenerator().- Returns:
- The key generator class
- Default:
- io.micronaut.cache.interceptor.DefaultCacheKeyGenerator.class
-
-
-
parameters
java.lang.String[] parameters
Limit the automaticCacheKeyGeneratorto the given parameter names. Mutually exclusive withkeyGenerator()- Returns:
- The parameter names that make up the key.
- Default:
- {}
-
-
-
async
boolean async
Whether the
CachePutoperation should be performed asynchronously and not block the returning valueThe value if
asyncimpacts behaviour in the following ways:- For blocking return types when the value is
falsethe 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
truethe method will return prior to cache writes occurring and errors will be logged via theAsyncCacheErrorHandler. - When the return type is a
CompletableFutureand the value isfalsethe future will not complete until theCachePutoperation is complete. - When the return type is a
CompletableFutureand the value istruethe future will complete prior to anyCachePutoperations 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
-
-