use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class TimespanCacheHandler method clean.
@Override
public void clean(PageContext pc) {
try {
Cache c = getCache(pc);
List<CacheEntry> entries = c.entries();
if (entries.size() < 100)
return;
Iterator<CacheEntry> it = entries.iterator();
while (it.hasNext()) {
// touch them to makes sure the cache remove them, not really good, cache must do this by itself
it.next();
}
} catch (IOException ioe) {
}
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheStorageScopeCleaner method clean.
private void clean(CacheConnection cc, ConfigWebImpl config) throws IOException {
Cache cache = cc.getInstance(config);
int len = filter.length(), index;
List<CacheEntry> entries = cache.entries(filter);
CacheEntry ce;
long expires;
String key, appname, cfid;
if (entries.size() > 0) {
Iterator<CacheEntry> it = entries.iterator();
while (it.hasNext()) {
ce = it.next();
Date lm = ce.lastModified();
long time = lm != null ? lm.getTime() : 0;
expires = time + ce.idleTimeSpan() - StorageScopeCache.SAVE_EXPIRES_OFFSET;
if (expires <= System.currentTimeMillis()) {
key = ce.getKey().substring(len);
index = key.indexOf(':');
cfid = key.substring(0, index);
appname = key.substring(index + 1);
if (listener != null)
listener.doEnd(engine, this, appname, cfid);
info("remove " + strType + "/" + appname + "/" + cfid + " from cache " + cc.getName());
engine.remove(type, appname, cfid);
cache.remove(ce.getKey());
}
}
}
// engine.remove(type,appName,cfid);
// return (Struct) cache.getValue(key,null);
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheGetAll method call.
public static Struct call(PageContext pc, String filter, String cacheName) throws PageException {
try {
Cache cache = CacheUtil.getCache(pc, cacheName, Config.CACHE_TYPE_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);
}
}
use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.
the class CacheEngine method list.
public Struct list(String filter) {
Struct sct = new StructImpl();
try {
List entries;
if (Util.isEmpty(filter))
entries = cache.entries();
else
entries = cache.entries(new WildCardFilter(filter, false));
Iterator it = entries.iterator();
CacheEntry entry;
while (it.hasNext()) {
entry = (CacheEntry) it.next();
sct.setEL(entry.getKey(), entry.getValue());
}
} catch (Exception e) {
SystemOut.printDate(e);
}
return sct;
}
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(CacheKeyFilter 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;
while (it.hasNext()) {
key = it.next();
if (filter.accept(key)) {
CacheEntry ce = getQuiet(key, null);
if (// possible that the entry is gone since keys(); call above
ce != null)
list.add(ce.getValue());
}
}
return list;
}
Aggregations