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;
}
Aggregations