Search in sources :

Example 1 with EvictionListener

use of org.apache.jackrabbit.oak.plugins.document.persistentCache.EvictionListener in project jackrabbit-oak by apache.

the class DocumentNodeStoreBuilder method buildCache.

@SuppressWarnings("unchecked")
private <K extends CacheValue, V extends CacheValue> Cache<K, V> buildCache(CacheType cacheType, long maxWeight, DocumentNodeStore docNodeStore, DocumentStore docStore) {
    Set<EvictionListener<K, V>> listeners = new CopyOnWriteArraySet<EvictionListener<K, V>>();
    Cache<K, V> cache = buildCache(cacheType.name(), maxWeight, listeners);
    PersistentCache p = null;
    if (cacheType == CacheType.DIFF || cacheType == CacheType.LOCAL_DIFF) {
        // use separate journal cache if configured
        p = getJournalCache();
    }
    if (p == null) {
        // otherwise fall back to single persistent cache
        p = getPersistentCache();
    }
    if (p != null) {
        cache = p.wrap(docNodeStore, docStore, cache, cacheType, statisticsProvider);
        if (cache instanceof EvictionListener) {
            listeners.add((EvictionListener<K, V>) cache);
        }
        PersistentCacheStats stats = PersistentCache.getPersistentCacheStats(cache);
        if (stats != null) {
            persistentCacheStats.put(cacheType, stats);
        }
    }
    return cache;
}
Also used : PersistentCache(org.apache.jackrabbit.oak.plugins.document.persistentCache.PersistentCache) PersistentCacheStats(org.apache.jackrabbit.oak.plugins.document.persistentCache.PersistentCacheStats) EvictionListener(org.apache.jackrabbit.oak.plugins.document.persistentCache.EvictionListener) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet)

Aggregations

CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 EvictionListener (org.apache.jackrabbit.oak.plugins.document.persistentCache.EvictionListener)1 PersistentCache (org.apache.jackrabbit.oak.plugins.document.persistentCache.PersistentCache)1 PersistentCacheStats (org.apache.jackrabbit.oak.plugins.document.persistentCache.PersistentCacheStats)1