Annotation 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
Author:
Graeme Rocher
  • Element Details

    • value

      @AliasFor(member="cacheNames") @AliasFor(annotation=CacheConfig.class,member="cacheNames") String[] value
      Returns:
      The cache names
      Default:
      {}
    • cacheNames

      @AliasFor(annotation=CacheConfig.class, member="cacheNames") String[] cacheNames
      Returns:
      The cache names
      Default:
      {}
    • parameters

      String[] parameters
      Limit the automatic CacheKeyGenerator to the given parameter names. Mutually exclusive with keyGenerator()
      Returns:
      The parameter names that make up the key.
      Default:
      {}
    • keyGenerator

      @AliasFor(annotation=CacheConfig.class, member="keyGenerator") @InstantiatedMember Class<? extends CacheKeyGenerator> 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 to true otherwise SyncCache.get(Object, Class) will be called which is non-atomic

      Note 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
    • condition

      String condition
      Evaluated 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:
      ""