Search in sources :

Example 1 with PageSourcePool

use of lucee.runtime.PageSourcePool in project Lucee by lucee.

the class Controler method removeOldest.

private void removeOldest(PageSourcePool[] pools) {
    PageSourcePool pool = null;
    String key = null;
    PageSource ps = null;
    long date = -1;
    for (int i = 0; i < pools.length; i++) {
        try {
            String[] keys = pools[i].keys();
            for (int y = 0; y < keys.length; y++) {
                ps = pools[i].getPageSource(keys[y], false);
                if (date == -1 || date > ps.getLastAccessTime()) {
                    pool = pools[i];
                    key = keys[y];
                    date = ps.getLastAccessTime();
                }
            }
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
            pools[i].clear();
        }
    }
    if (pool != null)
        pool.remove(key);
}
Also used : PageSourcePool(lucee.runtime.PageSourcePool) PageSource(lucee.runtime.PageSource)

Example 2 with PageSourcePool

use of lucee.runtime.PageSourcePool in project Lucee by lucee.

the class GetUsageData method templateCacheElements.

private static long[] templateCacheElements(Mapping[] mappings) {
    long elements = 0, size = 0;
    PageSourcePool psp;
    String[] keys;
    PageSourceImpl ps;
    Resource res;
    MappingImpl mapping;
    for (int i = 0; i < mappings.length; i++) {
        mapping = (MappingImpl) mappings[i];
        psp = mapping.getPageSourcePool();
        keys = psp.keys();
        for (int y = 0; y < keys.length; y++) {
            ps = (PageSourceImpl) psp.getPageSource(keys[y], false);
            if (ps.isLoad()) {
                elements++;
                res = mapping.getClassRootDirectory().getRealResource(ps.getClassName().replace('.', '/') + ".class");
                size += res.length();
            }
        }
    }
    return new long[] { elements, size };
}
Also used : Resource(lucee.commons.io.res.Resource) PageSourceImpl(lucee.runtime.PageSourceImpl) MappingImpl(lucee.runtime.MappingImpl) PageSourcePool(lucee.runtime.PageSourcePool)

Aggregations

PageSourcePool (lucee.runtime.PageSourcePool)2 Resource (lucee.commons.io.res.Resource)1 MappingImpl (lucee.runtime.MappingImpl)1 PageSource (lucee.runtime.PageSource)1 PageSourceImpl (lucee.runtime.PageSourceImpl)1