本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}