當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。