|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value={METHOD,TYPE}) @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.
cacheName()
specified a cache name of "my.app.DomainDao.getDomain(java.lang.String,int)"
will be generated.
Example using thepackage my.app; public class DomainDao { @CacheResult public Domain getDomain(String domainId, int index) { ... } }
CacheKey
annotation so that only the domainId parameter is used in key
generation
package my.app; public class DomainDao { @CacheResult public Domain getDomain(@CacheKey String domainId, Monitor mon) { ... } }
Optional Element Summary | |
---|---|
Class<? extends CacheKeyGenerator> |
cacheKeyGenerator
(Optional) The CacheKeyGenerator to use to generate the cache key used to call
Cache.put(Object, Object)
Defaults to a key generator that uses Arrays.deepHashCode(Object[]) and
Arrays.deepEquals(Object[], Object[]) with the array returned by
CacheKeyInvocationContext.getKeyParameters() |
String |
cacheName
(Optional) name of the cache. |
Class<? extends CacheResolverFactory> |
cacheResolverFactory
(Optional) The CacheResolverFactory to use to find the CacheResolver 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. |
public abstract String cacheName
CacheDefaults.cacheName()
an if that is not set it
defaults to: package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
public abstract boolean skipGet
CachePut
public abstract Class<? extends CacheResolverFactory> cacheResolverFactory
CacheResolverFactory
to use to find the CacheResolver
the intercepter will interact with.
Defaults to resolving the cache by name from the default CacheManager
public abstract Class<? extends CacheKeyGenerator> cacheKeyGenerator
CacheKeyGenerator
to use to generate the cache key used to call
Cache.put(Object, Object)
Defaults to a key generator that uses Arrays.deepHashCode(Object[])
and
Arrays.deepEquals(Object[], Object[])
with the array returned by
CacheKeyInvocationContext.getKeyParameters()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |