public class NodeDocumentCache extends Object implements Closeable
| Constructor and Description |
|---|
NodeDocumentCache(@NotNull Cache<org.apache.jackrabbit.oak.cache.CacheValue,NodeDocument> nodeDocumentsCache,
@NotNull org.apache.jackrabbit.oak.cache.CacheStats nodeDocumentsCacheStats,
@NotNull Cache<StringValue,NodeDocument> prevDocumentsCache,
@NotNull org.apache.jackrabbit.oak.cache.CacheStats prevDocumentsCacheStats,
@NotNull NodeDocumentLocks locks) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
@NotNull NodeDocument |
get(@NotNull String key,
@NotNull Callable<NodeDocument> valueLoader)
Return the document matching given key, optionally loading it from an
external source.
|
Iterable<org.apache.jackrabbit.oak.cache.CacheStats> |
getCacheStats() |
@Nullable NodeDocument |
getIfPresent(@NotNull String key)
Return the cached value or null.
|
void |
invalidate(@NotNull String key)
Invalidate document with given key.
|
int |
invalidateOutdated(@NotNull Map<String,ModificationStamp> modStamps)
Invalidate document with given keys iff their modification stamps are
different as passed in the map.
|
Iterable<org.apache.jackrabbit.oak.cache.CacheValue> |
keys() |
void |
markChanged(@NotNull String key)
Mark that the document with the given key is being changed.
|
void |
put(@NotNull NodeDocument doc)
Puts document into cache.
|
@NotNull NodeDocument |
putIfAbsent(@NotNull NodeDocument doc)
Puts document into cache iff no entry with the given key is cached
already.
|
@NotNull NodeDocument |
putIfNewer(@NotNull NodeDocument doc)
Puts document into cache iff no entry with the given key is cached
already or the cached document is older (has smaller
Document.MOD_COUNT). |
protected void |
putInternal(@NotNull NodeDocument doc)
Puts a document into the cache without acquiring a lock.
|
protected void |
putInternal(@NotNull NodeDocument doc,
@Nullable CacheChangesTracker trackerToSkip)
Puts a document into the cache without acquiring a lock.
|
void |
putNonConflictingDocs(CacheChangesTracker tracker,
Iterable<NodeDocument> docs)
Updates the cache with all the documents that:
(1) currently have their older versions in the cache or
(2) have been neither put nor invalidated during the tracker lifetime.
|
CacheChangesTracker |
registerTracker(Set<String> keys)
Registers a new CacheChangesTracker that records all puts and
invalidations related to the given documents
|
CacheChangesTracker |
registerTracker(String fromKey,
String toKey)
Registers a new CacheChangesTracker that records all puts and
invalidations related to children of the given parent.
|
void |
replaceCachedDocument(@NotNull NodeDocument oldDoc,
@NotNull NodeDocument newDoc)
Replaces the cached value if the old document is currently present in
the cache.
|
Iterable<NodeDocument> |
values() |
public NodeDocumentCache(@NotNull
@NotNull Cache<org.apache.jackrabbit.oak.cache.CacheValue,NodeDocument> nodeDocumentsCache,
@NotNull
@NotNull org.apache.jackrabbit.oak.cache.CacheStats nodeDocumentsCacheStats,
@NotNull
@NotNull Cache<StringValue,NodeDocument> prevDocumentsCache,
@NotNull
@NotNull org.apache.jackrabbit.oak.cache.CacheStats prevDocumentsCacheStats,
@NotNull
@NotNull NodeDocumentLocks locks)
public void invalidate(@NotNull
@NotNull String key)
key - to invalidatepublic void markChanged(@NotNull
@NotNull String key)
key - to markpublic int invalidateOutdated(@NotNull
@NotNull Map<String,ModificationStamp> modStamps)
modStamps - map where key is the document id and the value is the
modification stamps.@Nullable public @Nullable NodeDocument getIfPresent(@NotNull @NotNull String key)
key - document key@NotNull public @NotNull NodeDocument get(@NotNull @NotNull String key, @NotNull @NotNull Callable<NodeDocument> valueLoader) throws ExecutionException
This method can modify the cache, so it's synchronized. The getIfPresent(String)
is not synchronized and will be faster if you need to get the cached value
outside the critical section.
key - document keyvalueLoader - object used to retrieve the documentExecutionExceptionCache.get(Object, Callable)public void put(@NotNull
@NotNull NodeDocument doc)
doc - document to put@NotNull public @NotNull NodeDocument putIfNewer(@NotNull @NotNull NodeDocument doc)
Document.MOD_COUNT).doc - the document to add to the cachedoc or the document already present
in the cache if it's newer@NotNull public @NotNull NodeDocument putIfAbsent(@NotNull @NotNull NodeDocument doc)
doc - the document to add to the cache.doc or the document already present
in the cache.public void replaceCachedDocument(@NotNull
@NotNull NodeDocument oldDoc,
@NotNull
@NotNull NodeDocument newDoc)
oldDoc is not cached, nothing will happen. If
oldDoc does not match the document currently in the cache, then
the cached document is invalidated.oldDoc - the old documentnewDoc - the replacementpublic Iterable<org.apache.jackrabbit.oak.cache.CacheValue> keys()
public Iterable<NodeDocument> values()
public Iterable<org.apache.jackrabbit.oak.cache.CacheStats> getCacheStats()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic CacheChangesTracker registerTracker(String fromKey, String toKey)
fromKey - only keys larger than this key will be trackedtoKey - only keys smaller than this key will be trackedpublic CacheChangesTracker registerTracker(Set<String> keys)
keys - these documents will be trackedpublic void putNonConflictingDocs(CacheChangesTracker tracker, Iterable<NodeDocument> docs)
tracker - used to decide whether the docs should be put into cachedocs - to put into cacheprotected final void putInternal(@NotNull
@NotNull NodeDocument doc)
doc - the document to put into the cache.protected final void putInternal(@NotNull
@NotNull NodeDocument doc,
@Nullable
@Nullable CacheChangesTracker trackerToSkip)
trackerToSkip.doc - the document to put into the cache.trackerToSkip - this tracker won't be updated. pass null to update
all trackers.Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.