Annotation Type CacheRemove


  • @Target({METHOD,TYPE})
    @Retention(RUNTIME)
    public @interface CacheRemove
    When a method annotated with CacheRemove is invoked a GeneratedCacheKey will be generated and Cache.remove(Object) will be invoked on the specified cache.

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

    Example of removing a specific Domain object from the "domainCache". A GeneratedCacheKey will be generated from the String and int parameters and used to call Cache.remove(Object) after the deleteDomain method completes successfully.

    
     package my.app;
     
     public class DomainDao {
       @CacheRemove(cacheName="domainCache")
       public void deleteDomain(String domainId, int index) {
         ...
       }
     }
     

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

    1. If evictFor() and noEvictFor() are both empty then all exceptions prevent the remove
    2. If evictFor() is specified and noEvictFor() is not specified then only exceptions that pass an instanceof check against the evictFor list result in a remove
    3. If noEvictFor() is specified and evictFor() is not specified then all exceptions that do not pass an instanceof check against the noEvictFor result in a remove
    4. If evictFor() and noEvictFor() are both specified then exceptions that pass an instanceof check against the evictFor list but do not pass an instanceof check against the noEvictFor list result in a remove
    Since:
    1.0
    Author:
    Eric Dalquist, Rick Hightower, Greg Luck
    See Also:
    CacheKey