Search in sources :

Example 1 with CacheLIRS

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);
}
Also used : NodeDocumentLocks(org.apache.jackrabbit.oak.plugins.document.locks.NodeDocumentLocks) StripedNodeDocumentLocks(org.apache.jackrabbit.oak.plugins.document.locks.StripedNodeDocumentLocks) StripedNodeDocumentLocks(org.apache.jackrabbit.oak.plugins.document.locks.StripedNodeDocumentLocks) CacheValue(org.apache.jackrabbit.oak.cache.CacheValue) CacheStats(org.apache.jackrabbit.oak.cache.CacheStats) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) StringValue(org.apache.jackrabbit.oak.plugins.document.util.StringValue) CacheLIRS(org.apache.jackrabbit.oak.cache.CacheLIRS)

Example 2 with CacheLIRS

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;
}
Also used : Nonnull(javax.annotation.Nonnull) AtomicReference(java.util.concurrent.atomic.AtomicReference) CacheLIRS(org.apache.jackrabbit.oak.cache.CacheLIRS) PathRev(org.apache.jackrabbit.oak.plugins.document.PathRev) StringValue(org.apache.jackrabbit.oak.plugins.document.util.StringValue) File(java.io.File) Nullable(javax.annotation.Nullable) RemovalCause(com.google.common.cache.RemovalCause) Before(org.junit.Before)

Aggregations

CacheLIRS (org.apache.jackrabbit.oak.cache.CacheLIRS)2 StringValue (org.apache.jackrabbit.oak.plugins.document.util.StringValue)2 RemovalCause (com.google.common.cache.RemovalCause)1 File (java.io.File)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 CacheStats (org.apache.jackrabbit.oak.cache.CacheStats)1 CacheValue (org.apache.jackrabbit.oak.cache.CacheValue)1 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)1 PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)1 NodeDocumentLocks (org.apache.jackrabbit.oak.plugins.document.locks.NodeDocumentLocks)1 StripedNodeDocumentLocks (org.apache.jackrabbit.oak.plugins.document.locks.StripedNodeDocumentLocks)1 Before (org.junit.Before)1