Package io.micronaut.cache.annotation
Annotation Type Cacheable
-
@Target({METHOD,TYPE}) @Retention(RUNTIME) @Inherited @Documented @CacheConfig @CacheAnnotation public @interface Cacheable
An annotation that can be applied at the type or method level to indicate that the return value of the method should be cached for the configured
cacheNames()
.- Since:
- 1.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
atomic
Whether an atomic operation should be attempted to retrieve the cache value.java.lang.String[]
cacheNames
Alias forCacheConfig.cacheNames()
.java.lang.Class<? extends CacheKeyGenerator>
keyGenerator
Alias forCacheConfig.keyGenerator()
.java.lang.String[]
parameters
Limit the automaticCacheKeyGenerator
to the given parameter names.java.lang.String[]
value
Alias forCacheConfig.cacheNames()
.
-
-
-
Element Detail
-
value
@AliasFor(member="cacheNames") @AliasFor(annotation=CacheConfig.class,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:
- {}
-
-
-
parameters
java.lang.String[] parameters
Limit the automaticCacheKeyGenerator
to the given parameter names. Mutually exclusive withkeyGenerator()
- Returns:
- The parameter names that make up the key.
- Default:
- {}
-
-
-
keyGenerator
@AliasFor(annotation=CacheConfig.class, member="keyGenerator") @InstantiatedMember java.lang.Class<? extends CacheKeyGenerator> keyGenerator
Alias forCacheConfig.keyGenerator()
.- Returns:
- The cache key generator class
- Default:
- io.micronaut.cache.interceptor.DefaultCacheKeyGenerator.class
-
-
-
atomic
boolean atomic
Whether an atomic operation should be attempted to retrieve the cache value. This will call
SyncCache.get(Object, Class, java.util.function.Supplier)
if set totrue
otherwiseSyncCache.get(Object, Class)
will be called which is non-atomicNote that atomic operations will pick the first cache name specified and ignore the remaining.
- Returns:
- True if an atomic operation should be attempted
- Default:
- false
-
-