use of org.apache.jackrabbit.oak.cache.CacheLIRS in project jackrabbit-oak by apache.
the class CacheChangesTrackerTest method createCache.
private NodeDocumentCache createCache() {
Cache<CacheValue, NodeDocument> nodeDocumentsCache = new CacheLIRS<CacheValue, NodeDocument>(10);
Cache<StringValue, NodeDocument> prevDocumentsCache = new CacheLIRS<StringValue, NodeDocument>(10);
CacheStats nodeDocumentsCacheStats = Mockito.mock(CacheStats.class);
CacheStats prevDocumentsCacheStats = Mockito.mock(CacheStats.class);
NodeDocumentLocks locks = new StripedNodeDocumentLocks();
return new NodeDocumentCache(nodeDocumentsCache, nodeDocumentsCacheStats, prevDocumentsCache, prevDocumentsCacheStats, locks);
}
use of org.apache.jackrabbit.oak.cache.CacheLIRS in project jackrabbit-oak by apache.
the class AsyncQueueTest method setup.
@Before
public void setup() throws IOException {
FileUtils.deleteDirectory(new File("target/cacheTest"));
pCache = new PersistentCache("target/cacheTest");
final AtomicReference<NodeCache<PathRev, StringValue>> nodeCacheRef = new AtomicReference<NodeCache<PathRev, StringValue>>();
CacheLIRS<PathRev, StringValue> cache = new CacheLIRS.Builder<PathRev, StringValue>().maximumSize(1).evictionCallback(new CacheLIRS.EvictionCallback<PathRev, StringValue>() {
@Override
public void evicted(@Nonnull PathRev key, @Nullable StringValue value, @Nonnull RemovalCause cause) {
if (nodeCacheRef.get() != null) {
nodeCacheRef.get().evicted(key, value, cause);
}
}
}).build();
nodeCache = (NodeCache<PathRev, StringValue>) pCache.wrap(builderProvider.newBuilder().getNodeStore(), null, cache, CacheType.NODE);
nodeCacheRef.set(nodeCache);
CacheWriteQueueWrapper writeQueue = new CacheWriteQueueWrapper(nodeCache.writeQueue);
nodeCache.writeQueue = writeQueue;
this.putActions = writeQueue.putActions;
this.invalidateActions = writeQueue.invalidateActions;
this.id = 0;
}
Aggregations