本文整理匯總了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();
}
}
示例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;
}
示例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;
}
示例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: 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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}