Package javax.cache.annotation
In the case of a the CacheResult annotation,
if the cache can satisfy the request a result is returned by the method from
cache, not from method execution. For the mutative annotations such as
CacheResult the annotation allows the cached
value to be mutated so that it will be correct the next time
CacheResult is used.
Any operations against a cache via an annotation will have the same behaviour
as if the CacheResult methods were used. So
if the same underlying cache is used for an annotation and a direct API call,
the same data would be returned. Annotations therefore provide an additional
API for interacting with caches.
To use these annotations you'll need a library or framework that processes these annotations and intercepts calls to your application objects to provide the caching behaviour. This would commonly be provided by a dependency injection framework such as defined by CDI in Java EE.
- Since:
- 1.0
-
Interface Summary Interface Description CacheInvocationContext<A extends java.lang.annotation.Annotation> Runtime information about an intercepted method invocation for a method annotated withCacheResult,CachePut,CacheRemove, orCacheRemoveAllCacheInvocationParameter A parameter to an intercepted method invocation.CacheKeyGenerator Generates aGeneratedCacheKeybased on aCacheKeyInvocationContext.CacheKeyInvocationContext<A extends java.lang.annotation.Annotation> Runtime information about an intercepted method invocation for a method annotated withCacheResult,CachePut, orCacheRemove.CacheMethodDetails<A extends java.lang.annotation.Annotation> Static information about a method annotated with one of:CacheResult,CachePut,CacheRemove, orCacheRemoveAllCacheResolver Determines theCacheto use for an intercepted method invocation.CacheResolverFactory Determines theCacheResolverto use for an annotated method.GeneratedCacheKey ASerializable, immutable, thread-safe object that is used as a key, automatically generated by aCacheKeyGenerator. -
Annotation Types Summary Annotation Type Description CacheDefaults Allows the configuration of defaults forCacheResult,CachePut,CacheRemove, andCacheRemoveAllat the class level.CacheKey Marks a method argument as part of the cache key.CachePut When a method annotated withCachePutis invoked aGeneratedCacheKeywill be generated andCache.put(Object, Object)will be invoked on the specified cache storing the value marked withCacheValue.CacheRemove When a method annotated withCacheRemoveis invoked aGeneratedCacheKeywill be generated andCache.remove(Object)will be invoked on the specified cache.CacheRemoveAll When a method annotated withCacheRemoveAllis invoked all elements in the specified cache will be removed via theCache.removeAll()methodCacheResult When a method annotated withCacheResultis invoked aGeneratedCacheKeywill be generated andCache.get(Object)is called before the annotated method actually executes.CacheValue Marks the parameter to be cached for a method annotated withCachePut.