Search in sources :

Example 11 with CacheEntry

use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.

the class CacheSupport method remove.

@Override
public int remove(CacheEntryFilter filter) throws IOException {
    if (CacheUtil.allowAll(filter))
        return clear();
    List<String> keys = keys();
    int count = 0;
    Iterator<String> it = keys.iterator();
    String key;
    CacheEntry entry;
    while (it.hasNext()) {
        key = it.next();
        entry = getQuiet(key, null);
        if (filter == null || filter.accept(entry)) {
            remove(key);
            count++;
        }
    }
    return count;
}
Also used : CacheEntry(lucee.commons.io.cache.CacheEntry)

Example 12 with CacheEntry

use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.

the class CacheHandlerCollectionImpl method clear.

public static void clear(PageContext pc, Cache cache, CacheHandlerFilter filter) {
    try {
        Iterator<CacheEntry> it = cache.entries().iterator();
        CacheEntry ce;
        Object obj;
        while (it.hasNext()) {
            ce = it.next();
            if (filter == null) {
                cache.remove(ce.getKey());
                continue;
            }
            obj = ce.getValue();
            if (obj instanceof QueryCacheItem)
                obj = ((QueryCacheItem) obj).getQuery();
            if (filter.accept(obj))
                cache.remove(ce.getKey());
        }
    } catch (IOException e) {
    }
}
Also used : IOException(java.io.IOException) CacheEntry(lucee.commons.io.cache.CacheEntry) QueryCacheItem(lucee.runtime.cache.tag.query.QueryCacheItem)

Example 13 with CacheEntry

use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.

the class CacheComplex method entries.

private List<CacheEntry> entries(List<CacheEntry> entries) {
    if (entries == null || entries.size() == 0)
        return entries;
    Iterator<CacheEntry> it = entries.iterator();
    ArrayList<CacheEntry> list = new ArrayList<CacheEntry>(entries.size());
    CacheEntry entry;
    while (it.hasNext()) {
        entry = it.next();
        if (entry != null)
            list.add(new CacheComplexEntry(this, entry));
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) CacheEntry(lucee.commons.io.cache.CacheEntry)

Example 14 with CacheEntry

use of lucee.commons.io.cache.CacheEntry in project Lucee by lucee.

the class CacheResourceProvider method touch.

void touch(String path, String name) throws IOException {
    Cache cache = getCache();
    CacheEntry ce = cache.getCacheEntry(toKey(path, name), null);
    if (ce != null) {
        cache.put(ce.getKey(), ce.getValue(), ce.idleTimeSpan(), ce.liveTimeSpan());
    }
}
Also used : CacheEntry(lucee.commons.io.cache.CacheEntry) Cache(lucee.commons.io.cache.Cache) RamCache(lucee.runtime.cache.ram.RamCache)

Aggregations

CacheEntry (lucee.commons.io.cache.CacheEntry)14 ArrayList (java.util.ArrayList)5 Cache (lucee.commons.io.cache.Cache)5 IOException (java.io.IOException)4 StructImpl (lucee.runtime.type.StructImpl)4 Struct (lucee.runtime.type.Struct)3 RamCache (lucee.runtime.cache.ram.RamCache)2 WildCardFilter (lucee.runtime.cache.util.WildCardFilter)2 Date (java.util.Date)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CacheException (lucee.commons.io.cache.exp.CacheException)1 QueryCacheItem (lucee.runtime.cache.tag.query.QueryCacheItem)1 FunctionException (lucee.runtime.exp.FunctionException)1 PageException (lucee.runtime.exp.PageException)1 GetHttpTimeString (lucee.runtime.functions.dateTime.GetHttpTimeString)1 StorageScopeCache (lucee.runtime.type.scope.storage.StorageScopeCache)1