public class IndexCache<H extends ILocalBTreeView> extends ConcurrentWeakValueCacheWithTimeout<NT,H>
ConcurrentWeakValueCache to track the earliest timestamp
from which any local IIndex view is reading. This timestamp is
reported by getRetentionTime(). The StoreManager uses this
in StoreManager.purgeOldResources() to provide a "read lock" such
that resources for in use views are not released.ConcurrentWeakValueCache.WeakRef<K,V>DEBUG, INFO, log| Constructor and Description |
|---|
IndexCache(int cacheCapacity,
long cacheTimeoutMillis) |
| Modifier and Type | Method and Description |
|---|---|
long |
getRetentionTime()
The earliest timestamp that MUST be retained for the read-historical
indices in the cache and
Long.MAX_VALUE if there are NO
read-historical indices in the cache. |
H |
put(NT k,
H v)
Adds the key-value mapping to the cache.
|
H |
putIfAbsent(NT k,
H v)
Adds the key-value mapping to the cache iff there is no entry for that
key.
|
protected WeakReference<H> |
removeMapEntry(NT k)
Overridden to clear the
retentionTime if the map entry
corresponding to that timestamp is being removed from the map. |
capacity, clear, containsKey, didUpdate, entryIterator, get, isRemoveClearedReferences, iterator, newWeakRef, remove, removeClearedEntries, sizepublic IndexCache(int cacheCapacity,
long cacheTimeoutMillis)
cacheCapacity - The capacity of the backing hard reference queue.cacheTimeoutMillis - The timeout (milliseconds) before an entry which has not been
touched is cleared from the cache.public long getRetentionTime()
Long.MAX_VALUE if there are NO
read-historical indices in the cache.
Note: Due to the concurrent operations of the garbage collector, this
method MAY return a time that is earlier than necessary. This
possibility arises because WeakReference values may be
cleared at any time. There is no negative consequence to this
behavior - it simply means that fewer resources will be released than
might otherwise be possible. This "hole" can not be closed by polling
the ReferenceQueue since it is not when the entries are
removed from the map which matters, but when their
WeakReference values are cleared. However, periodically
clearing stale references using #clearStaleRefs() will keep
down the size of that "hole".
public H put(NT k, H v)
ConcurrentWeakValueCacheput in interface IConcurrentWeakValueCache<NT,H extends ILocalBTreeView>put in class ConcurrentWeakValueCache<NT,H extends ILocalBTreeView>k - The key.v - The value.null if there is
no entry under the key or if the entry under the key has has its
reference cleared.public H putIfAbsent(NT k, H v)
ConcurrentWeakValueCacheputIfAbsent in interface IConcurrentWeakValueCache<NT,H extends ILocalBTreeView>putIfAbsent in class ConcurrentWeakValueCache<NT,H extends ILocalBTreeView>k - The key.v - The value.protected WeakReference<H> removeMapEntry(NT k)
retentionTime if the map entry
corresponding to that timestamp is being removed from the map.removeMapEntry in class ConcurrentWeakValueCache<NT,H extends ILocalBTreeView>k - The key.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.