当前位置: 首页>>代码示例>>Java>>正文


Java Cache.evict方法代码示例

本文整理汇总了Java中org.springframework.cache.Cache.evict方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.evict方法的具体用法?Java Cache.evict怎么用?Java Cache.evict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.cache.Cache的用法示例。


在下文中一共展示了Cache.evict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performCacheEvict

import org.springframework.cache.Cache; //导入方法依赖的package包/类
private void performCacheEvict(CacheOperationContext context, CacheEvictOperation operation, Object result) {
	Object key = null;
	for (Cache cache : context.getCaches()) {
		if (operation.isCacheWide()) {
			logInvalidating(context, operation, null);
			cache.clear();
		}
		else {
			if (key == null) {
				key = context.generateKey(result);
			}
			logInvalidating(context, operation, key);
			cache.evict(key);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:CacheAspectSupport.java

示例2: doEvict

import org.springframework.cache.Cache; //导入方法依赖的package包/类
protected void doEvict(String cacheName, String key) {
    FluuzCache cache = cacheMap.get(cacheName);
    if (cache != null) {
        Cache proxy = cache.getProxy();
        proxy.evict(key);
        log.debug("evicted key '{}' from cache {}", key, cacheName);
    }
}
 
开发者ID:ArawakCC,项目名称:fluuz,代码行数:9,代码来源:RedisEventManager.java

示例3: addProduct

import org.springframework.cache.Cache; //导入方法依赖的package包/类
/**
 * Updates caches after a product insertion.
 *
 * @param retObject object returned by the annotated method.
 */
@AfterReturning(
      pointcut = "@annotation(fr.gael.dhus.spring.cache.AddProduct)",
      returning = "retObject")
public void addProduct(Object retObject)
{
   if (retObject != null && retObject instanceof Product)
   {
      Product p = (Product) retObject;

      // add the given product in cache
      Cache cache = getCacheManager().getCache(PRODUCT_CACHE_NAME);
      synchronized (cache)
      {
         cache.evict(p.getId());
         cache.evict(p.getUuid());
         cache.putIfAbsent(p.getId(), p);
         cache.putIfAbsent(p.getUuid(), p);
      }

      // increment global 'product_count' and clear others key
      cache = getCacheManager().getCache(PRODUCT_COUNT_CACHE_NAME);
      synchronized (cache)
      {
         Integer oldValue = cache.get(PRODUCT_COUNT_TOTAL_KEY, Integer.class);
         if (oldValue != null)
         {
            cache.clear();
            cache.putIfAbsent(PRODUCT_COUNT_TOTAL_KEY, (oldValue + 1));
         }
      }

      // clear 'products' cache
      getCacheManager().getCache(PRODUCTS_CACHE_NAME).clear();
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:41,代码来源:CacheAspectDefinition.java

示例4: evictFromCache

import org.springframework.cache.Cache; //导入方法依赖的package包/类
/**
 * 清除缓存中具体的 缓存数据
 *
 * @param cache Cache
 * @param key   Cache key
 * @return True is evict successful
 */
protected boolean evictFromCache(Cache cache, Object key) {
    if (key == null) {
        LOG.debug("Ignore evict from cache[{}], because key is null", cache);
        return false;
    }
    cache.evict(key);
    LOG.debug("Evict key[{}] from cache[{}]", key, cache);
    return true;
}
 
开发者ID:monkeyk,项目名称:oauth2-shiro-redis,代码行数:17,代码来源:AbstractCacheSupport.java

示例5: evictFromCache

import org.springframework.cache.Cache; //导入方法依赖的package包/类
/**
 * 删除缓存数据
 * @param cache
 * @param key
 * @return
 */
protected boolean evictFromCache(Cache cache,Object key){
    if(null == key){
        return false;
    }
    cache.evict(key);

    return true;
}
 
开发者ID:cwenao,项目名称:springboot_cwenao,代码行数:15,代码来源:AbstractCacheSupport.java

示例6: removeProduct

import org.springframework.cache.Cache; //导入方法依赖的package包/类
/**
 * Updates caches after a product deletion.
 *
 * @param retObject object returned by the annotated method.
 */
@AfterReturning(
      pointcut = "@annotation(fr.gael.dhus.spring.cache.RemoveProduct)",
      returning = "retObject")
public void removeProduct(Object retObject)
{
   if (retObject != null && retObject instanceof Product)
   {
      Product p = (Product) retObject;

      // remove the given product from cache
      Cache cache = getCacheManager().getCache(PRODUCT_CACHE_NAME);
      synchronized (cache)
      {
         cache.evict(p.getId());
         cache.evict(p.getUuid());
      }

      // clear 'indexes' cache of the given product
      cache = getCacheManager().getCache(INDEXES_CACHE_NAME);
      cache.evict(p.getId());

      // decrement global 'product_count' and clear others key
      cache = getCacheManager().getCache(PRODUCT_COUNT_CACHE_NAME);
      synchronized (cache)
      {
         // save old value of all processed products
         Integer oldValue = cache.get(PRODUCT_COUNT_TOTAL_KEY, Integer.class);

         // clear cache
         cache.clear();

         // update value for all processed products if necessary
         if (oldValue != null)
         {
            cache.putIfAbsent(PRODUCT_COUNT_TOTAL_KEY, (oldValue - 1));
         }
      }

      // clear 'products' cache
      getCacheManager().getCache(PRODUCTS_CACHE_NAME).clear();
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:48,代码来源:CacheAspectDefinition.java


注:本文中的org.springframework.cache.Cache.evict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。