本文整理匯總了Java中net.sf.ehcache.Cache.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Cache.get方法的具體用法?Java Cache.get怎麽用?Java Cache.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sf.ehcache.Cache
的用法示例。
在下文中一共展示了Cache.get方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: idleExample
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
private void idleExample() throws InterruptedException {
System.out.println("\nIdle example\n");
Cache testCache = EhcacheHelper.createIdleCache(manager, "idleCache");
testCache.put(new Element(0, "String: 0"));
testCache.get(0);
System.out.println("Hit count: " + testCache.getStatistics().cacheHitCount());
System.out.println("Miss count: " + testCache.getStatistics().cacheMissCount());
Thread.sleep(TimeUnit.SECONDS.toMillis(EhcacheHelper.IDLE_TIME_SEC) - 1);
testCache.get(0);
System.out.println("Hit count: " + testCache.getStatistics().cacheHitCount());
System.out.println("Miss count: " + testCache.getStatistics().cacheMissCount());
Thread.sleep(TimeUnit.SECONDS.toMillis(EhcacheHelper.IDLE_TIME_SEC) + 1);
testCache.get(0);
System.out.println("Hit count: " + testCache.getStatistics().cacheHitCount());
System.out.println("Miss count: " + testCache.getStatistics().cacheMissCount());
}
示例2: getCachedBuildRightSet
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
private BuildRights getCachedBuildRightSet(final int activeBuildID, final int userID) {
BuildRights buildRights = null;
try {
final Cache cache = getBuildRightSetCache(activeBuildID);
if (cache == null) {
return null;
}
final Element element = cache.get(new Integer(userID));
if (element != null) {
buildRights = (BuildRights) element.getValue();
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("e: " + e);
}
}
// if (log.isDebugEnabled()) log.debug("cached rightSet for build ID " + activeBuildID + ", user ID " + userID + " : " + rightSet);
return buildRights;
}
示例3: listCount
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public int listCount(Cnd c)
{
Long num = 0L;
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(CACHE_COUNT_KEY) == null)
{
num = Long.valueOf(this.count(c));
cache.put(new Element(CACHE_COUNT_KEY, num));
}else{
num = (Long)cache.get(CACHE_COUNT_KEY).getObjectValue();
}
return num.intValue();
}
示例4: listCount
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public int listCount(Condition c)
{
Long num = 0L;
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(CACHE_COUNT_KEY) == null)
{
num = Long.valueOf(this.count(c));
cache.put(new Element(CACHE_COUNT_KEY, num));
}else{
num = (Long)cache.get(CACHE_COUNT_KEY).getObjectValue();
}
return num.intValue();
}
示例5: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Unit> queryCache(Cnd c,Page p)
{
List<Unit> list_unit = null;
String cacheKey = "unit_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_unit = this.query(c, p);
cache.put(new Element(cacheKey, list_unit));
}else{
list_unit = (List<Unit>)cache.get(cacheKey).getObjectValue();
}
return list_unit;
}
示例6: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Linkman> queryCache(Cnd c,Page p)
{
List<Linkman> list_linkman = null;
String cacheKey = "linkman_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_linkman = this.query(c, p);
cache.put(new Element(cacheKey, list_linkman));
}else{
list_linkman = (List<Linkman>)cache.get(cacheKey).getObjectValue();
}
return list_linkman;
}
示例7: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Aftersales> queryCache(Cnd c,Page p)
{
List<Aftersales> list_aftersales = null;
String cacheKey = "aftersales_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_aftersales = this.query(c, p);
cache.put(new Element(cacheKey, list_aftersales));
}else{
list_aftersales = (List<Aftersales>)cache.get(cacheKey).getObjectValue();
}
return list_aftersales;
}
示例8: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Product> queryCache(Cnd c,Page p)
{
List<Product> list_product = null;
String cacheKey = "product_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_product = this.query(c, p);
cache.put(new Element(cacheKey, list_product));
}else{
list_product = (List<Product>)cache.get(cacheKey).getObjectValue();
}
return list_product;
}
示例9: get
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
/**
* 獲取緩存記錄
* @param cacheName
* @param key
* @return
*/
public static Object get(String cacheName, String key) {
Cache cache = getCache(cacheName);
if (null == cache) {
return null;
}
Element cacheElement = cache.get(key);
if (null == cacheElement) {
return null;
}
return cacheElement.getObjectValue();
}
示例10: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Product> queryCache(Condition c,Page p)
{
List<Product> list_product = null;
String cacheKey = "product_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_product = this.query(c, p);
cache.put(new Element(cacheKey, list_product));
}else{
list_product = (List<Product>)cache.get(cacheKey).getObjectValue();
}
return list_product;
}
示例11: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Sales> queryCache(Cnd c,Page p)
{
List<Sales> list_sales = null;
String cacheKey = "sales_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_sales = this.query(c, p);
cache.put(new Element(cacheKey, list_sales));
}else{
list_sales = (List<Sales>)cache.get(cacheKey).getObjectValue();
}
return list_sales;
}
示例12: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Blood> queryCache(Cnd c,Page p)
{
List<Blood> list_blood = null;
String cacheKey = "blood_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_blood = this.query(c, p);
cache.put(new Element(cacheKey, list_blood));
}else{
list_blood = (List<Blood>)cache.get(cacheKey).getObjectValue();
}
return list_blood;
}
示例13: queryCache
import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Code> queryCache(Condition c,Page p)
{
List<Code> list_code = null;
String cacheKey = "code_list_" + p.getPageCurrent();
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(cacheKey) == null)
{
list_code = this.query(c, p);
cache.put(new Element(cacheKey, list_code));
}else{
list_code = (List<Code>)cache.get(cacheKey).getObjectValue();
}
return list_code;
}