List of usage examples for org.springframework.cache.interceptor CacheEvictOperation isCacheWide
public boolean isCacheWide()
From source file:grails.plugin.cache.web.filter.PageFragmentCachingFilter.java
protected boolean inspectCacheEvicts(Collection<CacheOperationContext> evictions, boolean beforeInvocation) { if (evictions.isEmpty()) { return false; }//from w w w . ja v a2 s . c o m boolean trace = log.isTraceEnabled(); boolean atLeastOne = false; for (CacheOperationContext operationContext : evictions) { CacheEvictOperation evict = (CacheEvictOperation) operationContext.operation; if (beforeInvocation == evict.isBeforeInvocation()) { if (operationContext.isConditionPassing()) { atLeastOne = true; // for each cache // lazy key initialization Object key = null; for (Cache cache : operationContext.getCaches()) { // cache-wide flush if (evict.isCacheWide()) { cache.clear(); logRequestDetails(operationContext.request, getContext(), "Flushing request"); } else { // check key if (key == null) { key = operationContext.generateKey(); } if (trace) { log.trace("Invalidating cache key {} for operation {} on method {}", new Object[] { key, evict, operationContext.method }); } cache.evict(key); } } } else { logRequestDetails(operationContext.request, getContext(), "Not flushing request"); } } } return atLeastOne; }
From source file:org.springframework.cache.interceptor.CacheAspectSupport.java
private void performCacheEvict(CacheOperationContext context, CacheEvictOperation operation, @Nullable Object result) { Object key = null;// w w w . j a v a 2s . co m for (Cache cache : context.getCaches()) { if (operation.isCacheWide()) { logInvalidating(context, operation, null); doClear(cache); } else { if (key == null) { key = generateKey(context, result); } logInvalidating(context, operation, key); doEvict(cache, key); } } }
From source file:org.springframework.cache.interceptor.YJFCacheAspectSupport.java
private void inspectCacheEvicts(Collection<CacheOperationContext> evictions, boolean beforeInvocation) { if (!evictions.isEmpty()) { boolean log = logger.isTraceEnabled(); for (CacheOperationContext context : evictions) { CacheEvictOperation evictOp = (CacheEvictOperation) context.operation; if (beforeInvocation == evictOp.isBeforeInvocation()) { if (context.isConditionPassing()) { // for each cache // lazy key initialization Object key = null; for (Cache cache : context.getCaches()) { // cache-wide flush if (evictOp.isCacheWide()) { cache.clear(); if (log) { logger.trace("Invalidating entire cache for operation " + evictOp + " on method " + context.method); }//from w ww . j a va 2 s .c o m } else { // check key if (key == null) { key = context.generateKey(); } if (log) { logger.trace("Invalidating cache key " + key + " for operation " + evictOp + " on method " + context.method); } cache.evict(key); } } } else { if (log) { logger.trace("Cache condition failed on method " + context.method + " for operation " + context.operation); } } } } } }