javax.cache.interceptor
Annotation Type CacheResult


@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface CacheResult

When a method annotated with CacheResult is invoked a CacheKey will be generated and Cache.get(Object) is called before the invoked method actually executes. 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 with the generated key.

null return values and thrown exceptions are never cached.

Since:
1.7
Author:
Eric Dalquist

Optional Element Summary
 Class<? extends CacheKeyGenerator> cacheKeyGenerator
          (Optional) The CacheKeyGenerator to use to generate the cache key used to call Cache.get(Object) Cache.put(Object, Object)

Defaults to DefaultCacheKeyGenerator

 Class<? extends Annotation>[] cacheKeyGeneratorQualifiers
           
 String cacheName
          (Optional) name of the cache.
 Class<? extends Annotation>[] cacheResolverQualifiers
           
 Class<? extends CacheResolver> cacheResovler
          (Optional) The CacheResolver to use to find the Cache the intercepter will interact with.
 boolean skipGet
          (Optional) If set to true the pre-invocation get is skipped and the annotated method is always executed with the returned value being cached as normal.
 

cacheName

public abstract String cacheName
(Optional) name of the cache.

Defaults to ClassName.methodName

Default:
""

skipGet

public abstract boolean skipGet
(Optional) If set to true the pre-invocation get is skipped and the annotated method is always executed with the returned value being cached as normal. This is useful for create or update methods which should always be executed and have their returned value placed in the cache.

Defaults to false

Default:
false

cacheResovler

public abstract Class<? extends CacheResolver> cacheResovler
(Optional) The CacheResolver to use to find the Cache the intercepter will interact with.

Defaults to resolving the cache by name from the default CacheManager

Default:
javax.cache.interceptor.CacheResolver.class

cacheResolverQualifiers

public abstract Class<? extends Annotation>[] cacheResolverQualifiers
Default:
{}

cacheKeyGenerator

public abstract Class<? extends CacheKeyGenerator> cacheKeyGenerator
(Optional) The CacheKeyGenerator to use to generate the cache key used to call Cache.get(Object) Cache.put(Object, Object)

Defaults to DefaultCacheKeyGenerator

Default:
javax.cache.interceptor.DefaultCacheKeyGenerator.class

cacheKeyGeneratorQualifiers

public abstract Class<? extends Annotation>[] cacheKeyGeneratorQualifiers
Default:
{}


true