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


Java Cache.clear方法代码示例

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


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

示例1: updateCache

import org.springframework.cache.Cache; //导入方法依赖的package包/类
@AfterReturning ("@annotation(fr.gael.dhus.spring.cache.IncrementCache)")
public void updateCache (JoinPoint joinPoint)
{
   IncrementCache annotation = ((MethodSignature) joinPoint.getSignature ())
         .getMethod ().getAnnotation (IncrementCache.class);

   Cache cache = getCacheManager().getCache(annotation.name());
   if (cache != null)
   {
      synchronized (cache)
      {
         Integer old_value = cache.get (annotation.key (), Integer.class);
         cache.clear ();
         if (old_value == null)
         {
            return;
         }
         cache.put (annotation.key (), (old_value + annotation.value ()));
      }
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:22,代码来源:CacheAspectDefinition.java

示例2: 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

示例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: clearRegisteredCaches

import org.springframework.cache.Cache; //导入方法依赖的package包/类
public void clearRegisteredCaches() {
	log.info("### clear all the cache ###");
	for(String name: super.getCacheNames()){
		Cache cache = getCache(name);
		if (cache != null) {
			cache.clear();
		}
	}
}
 
开发者ID:profullstack,项目名称:spring-seed,代码行数:10,代码来源:ExpirableRedisCacheManager.java

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