use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class Cache method doGet.
private void doGet() throws PageException, IOException {
required("cache", "id", id);
required("cache", "name", name);
String id = Caster.toString(this.id);
if (metadata == null) {
pageContext.setVariable(name, CacheGet.call(pageContext, id, throwOnError, cachename));
} else {
lucee.commons.io.cache.Cache cache = CacheUtil.getCache(pageContext, cachename, Config.CACHE_TYPE_OBJECT);
CacheEntry entry = throwOnError ? cache.getCacheEntry(CacheUtil.key(id)) : cache.getCacheEntry(CacheUtil.key(id), null);
if (entry != null) {
pageContext.setVariable(name, entry.getValue());
pageContext.setVariable(metadata, entry.getCustomInfo());
} else {
pageContext.setVariable(metadata, new StructImpl());
}
}
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheGetMetadata method call.
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);
}
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheSupport method keys.
@Override
public List<String> keys(CacheEntryFilter filter) throws IOException {
boolean all = CacheUtil.allowAll(filter);
List<String> keys = keys();
List<String> list = new ArrayList<String>();
Iterator<String> it = keys.iterator();
String key;
CacheEntry entry;
while (it.hasNext()) {
key = it.next();
entry = getQuiet(key, null);
if (all || filter.accept(entry))
list.add(key);
}
return list;
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheSupport method values.
// there was the wrong generic type defined in the older interface, because of that we do not define a generic type at all here, just to be sure
@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;
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheSupport method entries.
@Override
public List<CacheEntry> entries(CacheEntryFilter filter) throws IOException {
List<String> keys = keys();
List<CacheEntry> list = new ArrayList<CacheEntry>();
Iterator<String> it = keys.iterator();
CacheEntry entry;
while (it.hasNext()) {
entry = getQuiet(it.next(), null);
if (filter.accept(entry))
list.add(entry);
}
return list;
}
Aggregations