當前位置: 首頁>>代碼示例>>Java>>正文


Java Cache.get方法代碼示例

本文整理匯總了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());
}
 
開發者ID:vitaly-chibrikov,項目名稱:otus_java_2017_10,代碼行數:17,代碼來源:EhcaheMain.java

示例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;
  }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:20,代碼來源:SecurityManager.java

示例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();
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:14,代碼來源:AftersalesService.java

示例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();
}
 
開發者ID:lq10001,項目名稱:product,代碼行數:14,代碼來源:CodeService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:UnitService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:LinkmanService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:AftersalesService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:ProductService.java

示例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();
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:18,代碼來源:EhCacheUtil.java

示例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;
}
 
開發者ID:lq10001,項目名稱:product,代碼行數:16,代碼來源:ProductService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:SalesService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:BloodService.java

示例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;
}
 
開發者ID:lq10001,項目名稱:product,代碼行數:16,代碼來源:CodeService.java


注:本文中的net.sf.ehcache.Cache.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。