boolean isKeyInCache(java.lang.Object key)
key - the key to check forElement getQuiet(java.lang.Object key) throws java.lang.IllegalStateException, CacheException
key - a serializable valuejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionisExpired(net.sf.ehcache.Element)boolean isExpired(Element element) throws java.lang.IllegalStateException, java.lang.NullPointerException
The element is expired if:
element - the element to checkjava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEjava.lang.NullPointerException - if the element is null
Element element=cache.getQuiet(key);
log.info("element:"+element);
if(element!=null){
log.info("cache.isExpired(element):"+cache.isExpired(element));
log.info("cacheName:" + cacheName + " key:" + key + " isExist:true");
return true;
}
else{
log.info("cacheName:" + cacheName + " key:" + key + " isExist:false");
return false;
}ehcache如何判断缓存数据是否存在--isKeyInCache
原文:https://www.cnblogs.com/liuys635/p/12590934.html