类 RangeCache<Key extends Comparable<Key>,Value extends io.netty.util.ReferenceCounted>
java.lang.Object
org.apache.bookkeeper.mledger.util.RangeCache<Key,Value>
- 类型参数:
Key- Cache key. Needs to be ComparableValue- Cache value
public class RangeCache<Key extends Comparable<Key>,Value extends io.netty.util.ReferenceCounted>
extends Object
Special type of cache where get() and delete() operations can be done over a range of keys.
-
嵌套类概要
嵌套类修饰符和类型类说明static interfaceInterface of a object that is able to the extract the "timestamp" of the cached values.static interfaceInterface of a object that is able to the extract the "weight" (size/cost/space) of the cached values. -
构造器概要
构造器构造器说明Construct a new RangeLruCache with default Weighter.RangeCache(RangeCache.Weighter<Value> weighter, RangeCache.TimestampExtractor<Value> timestampExtractor) Construct a new RangeLruCache. -
方法概要
修饰符和类型方法说明clear()Remove all the entries from the cache.evictLeastAccessedEntries(long minSize) evictLEntriesBeforeTimestamp(long maxTimestamp) protected longJust for testing.longgetSize()booleanInsert.removeRange(Key first, Key last, boolean lastInclusive)
-
构造器详细资料
-
RangeCache
public RangeCache()Construct a new RangeLruCache with default Weighter. -
RangeCache
public RangeCache(RangeCache.Weighter<Value> weighter, RangeCache.TimestampExtractor<Value> timestampExtractor) Construct a new RangeLruCache.- 参数:
weighter- a custom weighter to compute the size of each stored value
-
-
方法详细资料
-
put
Insert.- 参数:
key-value- ref counted value with at least 1 ref to pass on the cache- 返回:
- whether the entry was inserted in the cache
-
get
-
getRange
- 参数:
first- the first key in the rangelast- the last key in the range (inclusive)- 返回:
- a collections of the value found in cache
-
removeRange
public org.apache.commons.lang3.tuple.Pair<Integer,Long> removeRange(Key first, Key last, boolean lastInclusive) - 参数:
first-last-lastInclusive-- 返回:
- an pair of ints, containing the number of removed entries and the total size
-
evictLeastAccessedEntries
- 参数:
minSize-- 返回:
- a pair containing the number of entries evicted and their total size
-
evictLEntriesBeforeTimestamp
public org.apache.commons.lang3.tuple.Pair<Integer,Long> evictLEntriesBeforeTimestamp(long maxTimestamp) - 参数:
maxTimestamp- the max timestamp of the entries to be evicted- 返回:
- the tota
-
getNumberOfEntries
protected long getNumberOfEntries()Just for testing. Getting the number of entries is very expensive on the conncurrent map -
getSize
public long getSize() -
clear
Remove all the entries from the cache.- 返回:
- size of removed entries
-