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


Java Ehcache.put方法代码示例

本文整理汇总了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;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:24,代码来源:ArticleServiceImpl.java

示例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;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:24,代码来源:ProductServiceImpl.java

示例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!");
}
 
开发者ID:jbernach,项目名称:transandalus-backend,代码行数:34,代码来源:KmlBootstrapCacheLoader.java

示例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));
   	}
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:7,代码来源:EhcacheShiroCache.java


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