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


Java Cache.put方法代碼示例

本文整理匯總了Java中net.sf.ehcache.Cache.put方法的典型用法代碼示例。如果您正苦於以下問題:Java Cache.put方法的具體用法?Java Cache.put怎麽用?Java Cache.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.ehcache.Cache的用法示例。


在下文中一共展示了Cache.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cacheMonitor

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
@Around("execution(* org.packt.aop.transaction.dao.impl.EmployeeDaoImpl.getEmployees(..))")
public Object cacheMonitor(ProceedingJoinPoint joinPoint) throws Throwable  {
   logger.info("executing " + joinPoint.getSignature().getName());
   Cache cache = cacheManager.getCache("employeesCache");
  
   logger.info("cache detected is  " + cache.getName());
   logger.info("begin caching.....");
   String key = joinPoint.getSignature().getName();
   logger.info(key);
   if(cache.get(key) == null){
	   logger.info("caching new Object.....");
	   Object result = joinPoint.proceed();
	   cache.put(new Element(key, result)); 	   
	   return result;
   }else{
	   logger.info("getting cached Object.....");
	   return cache.get(key).getObjectValue();
   }
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:20,代碼來源:CacheListenerAspect.java

示例2: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Gender> queryCache(Cnd c,Page p)
{
    List<Gender> list_gender = null;
    String cacheKey = "gender_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_gender = this.query(c, p);
        cache.put(new Element(cacheKey, list_gender));
    }else{
        list_gender = (List<Gender>)cache.get(cacheKey).getObjectValue();
    }
    return list_gender;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:GenderService.java

示例3: cacheBuildRightSet

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
private BuildRights cacheBuildRightSet(final int activeBuildID, final int userID, final BuildRights buildRights) {
  try {
    final Cache cache = getBuildRightSetCache(activeBuildID);
    if (cache != null) {
      cache.put(new Element(new Integer(userID), buildRights));
    }
  } catch (CacheException e) {
    if (log.isDebugEnabled()) {
      log.debug("e: " + e);
    }
  }
  return buildRights;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:14,代碼來源:SecurityManager.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,代碼來源:AporiaService.java

示例5: evictedExample

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
private void evictedExample() {
    System.out.println("\nEternal example\n");
    Cache testCache = EhcacheHelper.createEternalCache(manager, "evictedCache");
    for (int i = 0; i < 2 * EhcacheHelper.MAX_ENTRIES; i++) {
        testCache.put(new Element(i, "Value: " + i));
    }
    System.out.println("Evicted count: " + testCache.getStatistics().cacheEvictedCount());
}
 
開發者ID:vitaly-chibrikov,項目名稱:otus_java_2017_10,代碼行數:9,代碼來源:EhcaheMain.java

示例6: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Xinyong> queryCache(Cnd c,Page p)
{
    List<Xinyong> list_xinyong = null;
    String cacheKey = "xinyong_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_xinyong = this.query(c, p);
        cache.put(new Element(cacheKey, list_xinyong));
    }else{
        list_xinyong = (List<Xinyong>)cache.get(cacheKey).getObjectValue();
    }
    return list_xinyong;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:XinyongService.java

示例7: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Productlevel> queryCache(Condition c,Page p)
{
    List<Productlevel> list_productlevel = null;
    String cacheKey = "productlevel_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_productlevel = this.query(c, p);
        cache.put(new Element(cacheKey, list_productlevel));
    }else{
        list_productlevel = (List<Productlevel>)cache.get(cacheKey).getObjectValue();
    }
    return list_productlevel;
}
 
開發者ID:lq10001,項目名稱:product,代碼行數:16,代碼來源:ProductlevelService.java

示例8: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Eventtype> queryCache(Cnd c,Page p)
{
    List<Eventtype> list_eventtype = null;
    String cacheKey = "eventtype_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_eventtype = this.query(c, p);
        cache.put(new Element(cacheKey, list_eventtype));
    }else{
        list_eventtype = (List<Eventtype>)cache.get(cacheKey).getObjectValue();
    }
    return list_eventtype;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:EventtypeService.java

示例9: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Employee> queryCache(Cnd c,Page p)
{
    List<Employee> list_employee = null;
    String cacheKey = "employee_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_employee = this.query(c, p);
        cache.put(new Element(cacheKey, list_employee));
    }else{
        list_employee = (List<Employee>)cache.get(cacheKey).getObjectValue();
    }
    return list_employee;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:EmployeeService.java

示例10: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Linktype> queryCache(Cnd c,Page p)
{
    List<Linktype> list_linktype = null;
    String cacheKey = "linktype_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_linktype = this.query(c, p);
        cache.put(new Element(cacheKey, list_linktype));
    }else{
        list_linktype = (List<Linktype>)cache.get(cacheKey).getObjectValue();
    }
    return list_linktype;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:LinktypeService.java

示例11: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Target> queryCache(Condition c,Page p)
{
    List<Target> list_target = null;
    String cacheKey = "target_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_target = this.query(c, p);
        cache.put(new Element(cacheKey, list_target));
    }else{
        list_target = (List<Target>)cache.get(cacheKey).getObjectValue();
    }
    return list_target;
}
 
開發者ID:lq10001,項目名稱:product,代碼行數:16,代碼來源:TargetService.java

示例12: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Customerevent> queryCache(Cnd c,Page p)
{
    List<Customerevent> list_customerevent = null;
    String cacheKey = "customerevent_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_customerevent = this.query(c, p);
        cache.put(new Element(cacheKey, list_customerevent));
    }else{
        list_customerevent = (List<Customerevent>)cache.get(cacheKey).getObjectValue();
    }
    return list_customerevent;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:CustomereventService.java

示例13: put

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
/**
 * 新增緩存記錄
 * @param cacheName
 * @param key
 * @param value
 */
public static void put(String cacheName, String key, Object value) {
    Cache cache = getCache(cacheName);
    if (null != cache) {
        Element element = new Element(key, value);
        cache.put(element);
    }
}
 
開發者ID:ChangyiHuang,項目名稱:shuzheng,代碼行數:14,代碼來源:EhCacheUtil.java

示例14: 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,代碼來源:GenderService.java

示例15: queryCache

import net.sf.ehcache.Cache; //導入方法依賴的package包/類
public List<Party> queryCache(Cnd c,Page p)
{
    List<Party> list_party = null;
    String cacheKey = "party_list_" + p.getPageCurrent();

    Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
    if(cache.get(cacheKey) == null)
    {
        list_party = this.query(c, p);
        cache.put(new Element(cacheKey, list_party));
    }else{
        list_party = (List<Party>)cache.get(cacheKey).getObjectValue();
    }
    return list_party;
}
 
開發者ID:lq10001,項目名稱:crm,代碼行數:16,代碼來源:PartyService.java


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