Search in sources :

Example 1 with RamCache

use of lucee.runtime.cache.ram.RamCache in project Lucee by lucee.

the class CacheResourceProvider method getCache.

public Cache getCache() {
    PageContext pc = ThreadLocalPageContext.get();
    Cache c = CacheUtil.getDefault(pc, Config.CACHE_TYPE_RESOURCE, null);
    if (c == null) {
        // CFMLEngineImpl e=null;
        if (defaultCache == null) {
            defaultCache = new RamCache().init(0, 0, RamCache.DEFAULT_CONTROL_INTERVAL);
        }
        c = defaultCache;
    }
    if (!inits.contains(c.hashCode())) {
        String k = toKey("null", "");
        try {
            if (!c.contains(k)) {
                CacheResourceCore value = new CacheResourceCore(CacheResourceCore.TYPE_DIRECTORY, null, "");
                c.put(k, value, Constants.LONG_ZERO, Constants.LONG_ZERO);
            }
        } catch (IOException e) {
        // simply ignore
        }
        inits.add(c.hashCode());
    }
    return c;
}
Also used : PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) IOException(java.io.IOException) RamCache(lucee.runtime.cache.ram.RamCache) Cache(lucee.commons.io.cache.Cache) RamCache(lucee.runtime.cache.ram.RamCache)

Example 2 with RamCache

use of lucee.runtime.cache.ram.RamCache in project Lucee by lucee.

the class TimespanCacheHandler method getCache.

private Cache getCache(PageContext pc) {
    Cache cache = CacheUtil.getDefault(pc, cacheType, null);
    if (cache == null) {
        if (defaultCache == null) {
            RamCache rm = new RamCache().init(0, 0, RamCache.DEFAULT_CONTROL_INTERVAL);
            rm.decouple();
            defaultCache = rm;
        }
        return defaultCache;
    }
    if (cache instanceof CachePro)
        return ((CachePro) cache).decouple();
    return cache;
}
Also used : CachePro(lucee.commons.io.cache.CachePro) RamCache(lucee.runtime.cache.ram.RamCache) Cache(lucee.commons.io.cache.Cache) RamCache(lucee.runtime.cache.ram.RamCache)

Example 3 with RamCache

use of lucee.runtime.cache.ram.RamCache in project Lucee by lucee.

the class ConfigImpl method createRAMCache.

// used by argus cache FUTURE add to interface
/**
 * creates a new RamCache, please make sure to finalize.
 * @param arguments possible arguments are "timeToLiveSeconds", "timeToIdleSeconds" and "controlInterval"
 * @throws IOException
 */
public Cache createRAMCache(Struct arguments) throws IOException {
    RamCache rc = new RamCache();
    if (arguments == null)
        arguments = new StructImpl();
    rc.init(this, "" + CreateUniqueId.invoke(), arguments);
    return rc;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) RamCache(lucee.runtime.cache.ram.RamCache)

Aggregations

RamCache (lucee.runtime.cache.ram.RamCache)3 Cache (lucee.commons.io.cache.Cache)2 IOException (java.io.IOException)1 CachePro (lucee.commons.io.cache.CachePro)1 PageContext (lucee.runtime.PageContext)1 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)1 StructImpl (lucee.runtime.type.StructImpl)1