javax.cache.interceptor
Annotation Type CacheResult


@Target(value={METHOD,TYPE})
@Retention(value=RUNTIME)
@InterceptorBinding
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, Rick Hightower

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 CacheKeyGenerator

 String cacheName
          (Optional) name of the cache.
 Class<? extends CacheResolver> cacheResolver
          (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(argument type, argument type)

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

cacheResolver

public abstract Class<? extends CacheResolver> cacheResolver
(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

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 CacheKeyGenerator

Default:
javax.cache.interceptor.CacheKeyGenerator.class


Copyright © 2011. All Rights Reserved.