本文整理汇总了Java中net.sf.ehcache.Ehcache.put方法的典型用法代码示例。如果您正苦于以下问题:Java Ehcache.put方法的具体用法?Java Ehcache.put怎么用?Java Ehcache.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.ehcache.Ehcache
的用法示例。
在下文中一共展示了Ehcache.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: load
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
@Override
@Transactional
public void load(Ehcache ehcache) throws CacheException {
int i = 1, total = 12;
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", false, false), kmlService.getAllStagesKml("track", false, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", false, true), kmlService.getAllStagesKml("track", false, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", true, false), kmlService.getAllStagesKml("track", true, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("track", true, true), kmlService.getAllStagesKml("track", true, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", false, false), kmlService.getAllStagesKml("marcadores", false, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", false, true), kmlService.getAllStagesKml("marcadores", false, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", true, false), kmlService.getAllStagesKml("marcadores", true, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("marcadores", true, true), kmlService.getAllStagesKml("marcadores", true, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", false, false), kmlService.getAllStagesKml("servicios", false, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", false, true), kmlService.getAllStagesKml("servicios", false, true), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", true, false), kmlService.getAllStagesKml("servicios", true, false), true));
log.info("Caching KML {}/{}...", i++, total);
ehcache.put(new Element(new SimpleKey("servicios", true, true), kmlService.getAllStagesKml("servicios", true, true), true));
log.info("Caching done!");
}
示例4: setex
import net.sf.ehcache.Ehcache; //导入方法依赖的package包/类
public void setex(String key, V value) throws Exception {
if(cache.getNativeCache() instanceof Ehcache) {
Ehcache ehcache = (Ehcache) cache.getNativeCache();
ehcache.put(new Element(key, value));
}
}