use of lucee.commons.io.cache.Cache in project Lucee by lucee.
the class CacheUtil method remove.
public static void remove(ConfigWeb config, CacheConnection cc) throws Throwable {
Cache c = cc.getInstance(config);
// FUTURE no reflection needed
Method remove = null;
try {
remove = c.getClass().getMethod("remove", new Class[0]);
} catch (Exception ioe) {
c.remove((CacheEntryFilter) null);
return;
}
try {
remove.invoke(c, new Object[0]);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
use of lucee.commons.io.cache.Cache in project Lucee by lucee.
the class CacheUtil method release.
public static void release(CacheConnection cc) throws IOException {
Cache c = ((CacheConnectionPlus) cc).getLoadedInstance();
if (c == null)
return;
// FUTURE no reflection needed
Method release = null;
try {
release = c.getClass().getMethod("release", new Class[] {});
} catch (Exception e) {
return;
}
try {
if (release != null)
release.invoke(c, new Object[] {});
} catch (Exception e) {
throw ExceptionUtil.toIOException(e);
}
}
use of lucee.commons.io.cache.Cache in project Lucee by lucee.
the class CacheItem method getInstance.
public static CacheItem getInstance(PageContext pc, String id, String key, boolean useId, Resource dir, String cacheName, TimeSpan timespan) throws IOException {
HttpServletRequest req = pc.getHttpServletRequest();
Cache cache = CacheUtil.getCache(pc, cacheName, Config.CACHE_TYPE_TEMPLATE, null);
if (cache != null)
return new CacheItemCache(pc, req, id, key, useId, cache, timespan);
return new CacheItemFS(pc, req, id, key, useId, dir);
}
use of lucee.commons.io.cache.Cache 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.Cache in project Lucee by lucee.
the class IKHandlerCache method loadData.
@Override
public IKStorageValue loadData(PageContext pc, String appName, String name, String strType, int type, Log log) throws PageException {
Cache cache = getCache(pc, name);
String key = getKey(pc.getCFID(), appName, strType);
synchronized (cache) {
// sync necessary?
Object val = cache.getValue(key, null);
if (val instanceof byte[][]) {
ScopeContext.info(log, "load existing data from cache [" + name + "] to create " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID());
return new IKStorageValue((byte[][]) val);
} else if (val instanceof IKStorageValue) {
ScopeContext.info(log, "load existing data from cache [" + name + "] to create " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID());
return (IKStorageValue) val;
} else {
ScopeContext.info(log, "create new " + strType + " scope for " + pc.getApplicationContext().getName() + "/" + pc.getCFID() + " in cache [" + name + "]");
}
return null;
}
}
Aggregations