本文整理汇总了Java中lucee.commons.io.cache.CacheEntry类的典型用法代码示例。如果您正苦于以下问题:Java CacheEntry类的具体用法?Java CacheEntry怎么用?Java CacheEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheEntry类属于lucee.commons.io.cache包,在下文中一共展示了CacheEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCacheEntry
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public CacheEntry getCacheEntry(String key, CacheEntry defaultValue) {
DBCursor cur = null;
DBCollection coll = getCollection();
BasicDBObject query = new BasicDBObject("key", key.toLowerCase());
// be sure to flush
flushInvalid(coll,query);
cur = coll.find(query);
if (cur.count() > 0) {
hits++;
MongoDBCacheDocument doc = new MongoDBCacheDocument((BasicDBObject) cur.next());
doc.addHit();
//update the statistic and persist
save(doc,0);
return new MongoDBCacheEntry(doc);
}
misses++;
return defaultValue;
}
示例2: getInfo
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public static Struct getInfo(Struct info,CacheEntry ce) {
if(info==null) info=new StructImpl();
info.setEL("key", ce.getKey());
info.setEL("created", ce.created());
info.setEL("last_hit", ce.lastHit());
info.setEL("last_modified", ce.lastModified());
info.setEL("hit_count", new Double(ce.hitCount()));
info.setEL("size", new Double(ce.size()));
info.setEL("idle_time_span", toTimespan(ce.idleTimeSpan()));
info.setEL("live_time_span", toTimespan(ce.liveTimeSpan()));
return info;
}
示例3: getCacheEntry
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public CacheEntry getCacheEntry(String key) throws CacheException {
try {
misses++;
Element el = getCache().get(key);
if(el==null)throw new CacheException("there is no entry in cache with key ["+key+"]");
hits++;
misses--;
return new EHCacheEntry(el);
}
catch(IllegalStateException ise) {
throw new CacheException(ise.getMessage());
}
catch(net.sf.ehcache.CacheException ce) {
throw new CacheException(ce.getMessage());
}
}
示例4: getMeta2
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public CacheEntry getMeta2(String cacheName) throws IOException {
HttpURLConnection connection = (HttpURLConnection) toURL(cacheName).openConnection();
connection.setRequestMethod("HEAD");
connection.connect();
InputStream is=null;
try {
//is=connection.getInputStream();
//obj=getContent(connection);
//CacheFactory cf = new CacheFactory(is);
}
finally {
Util.closeEL(is);
disconnectEL(connection);
}
return null;
}
示例5: getEntry
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public CacheEntry getEntry(String cacheName,String key) throws IOException {
Object obj=null;
HttpURLConnection connection = (HttpURLConnection) toURL(cacheName, key).openConnection();
connection.setRequestMethod("GET");
connection.connect();
try {
connection.getContentLength();
connection.getHeaderField("Expires");
connection.getHeaderField("Last-Modified");
obj=getContent(connection);
}
finally {
disconnectEL(connection);
}
return new RESTCacheEntry(key,obj);
}
示例6: _get
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
private CacheEntry _get(String cacheName,String method,String key) throws ServiceException, MalformedURLException, RemoteException {
Service service = new Service();
Call call = (Call) service.createCall();
call.registerTypeMapping(
Element.class,
element,
BeanSerializerFactory.class,
BeanDeserializerFactory.class);
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("http://soap.server.ehcache.sf.net/", method));
call.addParameter("arg0", Constants.XSD_STRING, String.class, ParameterMode.IN);
call.addParameter("arg1", Constants.XSD_STRING, String.class, ParameterMode.IN);
call.setReturnClass(Element.class);
call.setReturnQName(element);
return new SoapCacheEntry((Element) call.invoke( new Object[] {cacheName,key } ));
}
示例7: clear
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public static void clear(PageContext pc, Cache cache, CacheHandlerFilter filter) {
try{
Iterator<CacheEntry> it = cache.entries().iterator();
CacheEntry ce;
Object obj;
while(it.hasNext()){
ce = it.next();
if(filter==null) {
cache.remove(ce.getKey());
continue;
}
obj=ce.getValue();
if(obj instanceof QueryCacheItem)
obj=((QueryCacheItem)obj).getQuery();
if(filter.accept(obj))
cache.remove(ce.getKey());
}
}
catch (IOException e) {}
}
示例8: values
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
@Override
public List values(CacheEntryFilter filter) throws IOException {
if(CacheUtil.allowAll(filter)) return values();
List<String> keys = keys();
List<Object> list=new ArrayList<Object>();
Iterator<String> it = keys.iterator();
String key;
CacheEntry entry;
while(it.hasNext()){
key=it.next();
entry=getQuiet(key,null);
if(filter.accept(entry))list.add(entry.getValue());
}
return list;
}
示例9: remove
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
@Override
public int remove(CacheEntryFilter filter) throws IOException {
if(CacheUtil.allowAll(filter)) return clear();
List<String> keys = keys();
int count=0;
Iterator<String> it = keys.iterator();
String key;
CacheEntry entry;
while(it.hasNext()){
key=it.next();
entry=getQuiet(key,null);
if(filter==null || filter.accept(entry)){
remove(key);
count++;
}
}
return count;
}
示例10: call
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public static Struct call(PageContext pc, String id, String cacheName) throws PageException {
try {
Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
CacheEntry entry = cache.getCacheEntry(Util.key(id));
Struct info=new StructImpl();
info.set(CACHE_HITCOUNT, new Double(cache.hitCount()));
info.set(CACHE_MISSCOUNT, new Double(cache.missCount()));
info.set(CACHE_CUSTOM, cache.getCustomInfo());
info.set(KeyConstants._custom, entry.getCustomInfo());
info.set(CREATED_TIME, entry.created());
info.set(KeyConstants._hitcount, new Double(entry.hitCount()));
info.set(IDLE_TIME, new Double(entry.idleTimeSpan()));
info.set(LAST_HIT, entry.lastHit());
info.set(LAST_UPDATED, entry.lastModified());
info.set(KeyConstants._size, new Double(entry.size()));
info.set(KeyConstants._timespan, new Double(entry.liveTimeSpan()));
return info;
} catch (IOException e) {
throw Caster.toPageException(e);
}
}
示例11: call
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public static Struct call(PageContext pc,String filter, String cacheName) throws PageException {
try {
Cache cache = Util.getCache(pc,cacheName,ConfigImpl.CACHE_DEFAULT_OBJECT);
List<CacheEntry> entries = CacheGetAllIds.isFilter(filter)?cache.entries(new WildCardFilter(filter,true)):cache.entries();
Iterator<CacheEntry> it=entries.iterator();
Struct sct = new StructImpl();
CacheEntry entry;
while(it.hasNext()){
entry= it.next();
sct.setEL(KeyImpl.getInstance(entry.getKey()),entry.getValue());
}
return sct;
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
示例12: onExpires
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public void onExpires(CacheEntry entry) {
String key=entry.getKey();
// type
int index=key.indexOf(':'),last;
//String type=key.substring(0,index);
// cfid
last=index+1;
index=key.indexOf(':',last);
String cfid=key.substring(last,index);
// appName
last=index+1;
index=key.indexOf(':',last);
String appName=key.substring(last);
Config config = ThreadLocalPageContext.getConfig();
_doEnd((CFMLFactoryImpl) config.getFactory(), appName, cfid);
}
示例13: values
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
@Override
public List values(CacheEntryFilter filter) throws IOException {
if(CacheUtil.allowAll(filter)) return values();
List<String> keys = keys();
List<Object> list=new ArrayList<Object>();
Iterator<String> it = keys.iterator();
String key;
CacheEntry entry;
while(it.hasNext()){
key=it.next();
entry=getQuiet(key,null);
if(filter.accept(entry))list.add(entry.getValue());
}
return list;
}
示例14: remove
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
@Override
public int remove(CacheEntryFilter filter) throws IOException {
if(CacheUtil.allowAll(filter)) return clear();
List<String> keys = keys();
int count=0;
Iterator<String> it = keys.iterator();
String key;
CacheEntry entry;
while(it.hasNext()){
key=it.next();
entry=getQuiet(key,null);
if(filter==null || filter.accept(entry)){
remove(key);
count++;
}
}
return count;
}
示例15: call
import lucee.commons.io.cache.CacheEntry; //导入依赖的package包/类
public static Struct call(PageContext pc, String id, String cacheName) throws PageException {
try {
Cache cache = CacheUtil.getCache(pc,cacheName,Config.CACHE_TYPE_OBJECT);
CacheEntry entry = cache.getCacheEntry(CacheUtil.key(id));
Struct info=new StructImpl();
info.set(CACHE_HITCOUNT, new Double(cache.hitCount()));
info.set(CACHE_MISSCOUNT, new Double(cache.missCount()));
info.set(CACHE_CUSTOM, cache.getCustomInfo());
info.set(KeyConstants._custom, entry.getCustomInfo());
info.set(CREATED_TIME, entry.created());
info.set(KeyConstants._hitcount, new Double(entry.hitCount()));
info.set(IDLE_TIME, new Double(entry.idleTimeSpan()));
info.set(LAST_HIT, entry.lastHit());
info.set(LAST_UPDATED, entry.lastModified());
info.set(KeyConstants._size, new Double(entry.size()));
info.set(KeyConstants._timespan, new Double(entry.liveTimeSpan()));
return info;
} catch (IOException e) {
throw Caster.toPageException(e);
}
}