Annotation Type CachePut


@Target({METHOD,TYPE}) @Retention(RUNTIME) public @interface CachePut
When a method annotated with CachePut is invoked a GeneratedCacheKey will be generated and Cache.put(Object, Object) will be invoked on the specified cache storing the value marked with CacheValue.

The default behavior is to call Cache.put(Object, Object) after the annotated method is invoked, this behavior can be changed by setting afterInvocation() to false in which case Cache.put(Object, Object) will be called before the annotated method is invoked.

Example of caching the Domain object with a key generated from the String and int parameters. The CacheValue annotation is used to designate which parameter should be stored in the "domainDao" cache.


 package my.app;
 
 public class DomainDao {
   @CachePut(cacheName="domainCache")
   public void updateDomain(String domainId, int index, @CacheValue Domain
 domain) {
     ...
   }
 }
 

Exception Handling, only used if afterInvocation() is true.

  1. If cacheFor() and noCacheFor() are both empty then all exceptions prevent the put
  2. If cacheFor() is specified and noCacheFor() is not specified then only exceptions that pass an instanceof check against the cacheFor list result in a put
  3. If noCacheFor() is specified and cacheFor() is not specified then all exceptions that do not pass an instanceof check against the noCacheFor result in a put
  4. If cacheFor() and noCacheFor() are both specified then exceptions that pass an instanceof check against the cacheFor list but do not pass an instanceof check against the noCacheFor list result in a put
Since:
1.0
See Also: