當前位置: 首頁>>代碼示例>>Java>>正文


Java Ehcache.removeAll方法代碼示例

本文整理匯總了Java中net.sf.ehcache.Ehcache.removeAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Ehcache.removeAll方法的具體用法?Java Ehcache.removeAll怎麽用?Java Ehcache.removeAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.ehcache.Ehcache的用法示例。


在下文中一共展示了Ehcache.removeAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMessage

import net.sf.ehcache.Ehcache; //導入方法依賴的package包/類
@Override
public void onMessage(final Message<CacheEvictionEvent> message) {
    CacheEvictionEvent event = message.getMessageObject();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Received cache eviction event: " + event);
    }
    Ehcache cache = cacheManager.getEhcache(event.getName());
    // No need to evict something in a cache which was not yet created
    if (cache != null) {
        Object key = event.getKey();
        if (key == null) {
            cache.removeAll(true);
        } else {
            cache.remove(key, true);
        }
    }
}
 
開發者ID:mateli,項目名稱:OpenCyclos,代碼行數:18,代碼來源:HazelcastCacheManagerPeerProvider.java

示例2: viewHits

import net.sf.ehcache.Ehcache; //導入方法依賴的package包/類
public long viewHits(Long id) {
	Ehcache cache = cacheManager.getEhcache(Article.HITS_CACHE_NAME);
	Element element = cache.get(id);
	Long hits;
	if (element != null) {
		hits = (Long) element.getObjectValue();
	} else {
		Article article = articleDao.find(id);
		if (article == null) {
			return 0L;
		}
		hits = article.getHits();
	}
	hits++;
	cache.put(new Element(id, hits));
	long time = System.currentTimeMillis();
	if (time > viewHitsTime + Article.HITS_CACHE_INTERVAL) {
		viewHitsTime = time;
		updateHits();
		cache.removeAll();
	}
	return hits;
}
 
開發者ID:justinbaby,項目名稱:my-paper,代碼行數:24,代碼來源:ArticleServiceImpl.java

示例3: viewHits

import net.sf.ehcache.Ehcache; //導入方法依賴的package包/類
public long viewHits(Long id) {
	Ehcache cache = cacheManager.getEhcache(Product.HITS_CACHE_NAME);
	Element element = cache.get(id);
	Long hits;
	if (element != null) {
		hits = (Long) element.getObjectValue();
	} else {
		Product product = productDao.find(id);
		if (product == null) {
			return 0L;
		}
		hits = product.getHits();
	}
	hits++;
	cache.put(new Element(id, hits));
	long time = System.currentTimeMillis();
	if (time > viewHitsTime + Product.HITS_CACHE_INTERVAL) {
		viewHitsTime = time;
		updateHits();
		cache.removeAll();
	}
	return hits;
}
 
開發者ID:justinbaby,項目名稱:my-paper,代碼行數:24,代碼來源:ProductServiceImpl.java


注:本文中的net.sf.ehcache.Ehcache.removeAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。