Key - Cache key. Needs to be ComparableValue - Cache valuepublic class RangeCache<Key extends Comparable<Key>,Value extends io.netty.util.ReferenceCounted> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
RangeCache.TimestampExtractor<ValueT>
Interface of a object that is able to the extract the "timestamp" of the cached values.
|
static interface |
RangeCache.Weighter<ValueT>
Interface of a object that is able to the extract the "weight" (size/cost/space) of the cached values.
|
| Constructor and Description |
|---|
RangeCache()
Construct a new RangeLruCache with default Weighter.
|
RangeCache(RangeCache.Weighter<Value> weighter,
RangeCache.TimestampExtractor<Value> timestampExtractor)
Construct a new RangeLruCache.
|
| Modifier and Type | Method and Description |
|---|---|
long |
clear()
Remove all the entries from the cache.
|
org.apache.commons.lang3.tuple.Pair<Integer,Long> |
evictLeastAccessedEntries(long minSize) |
long |
evictLEntriesBeforeTimestamp(long maxTimestamp) |
Value |
get(Key key) |
protected long |
getNumberOfEntries()
Just for testing.
|
Collection<Value> |
getRange(Key first,
Key last) |
long |
getSize() |
boolean |
put(Key key,
Value value)
Insert.
|
org.apache.commons.lang3.tuple.Pair<Integer,Long> |
removeRange(Key first,
Key last,
boolean lastInclusive) |
public RangeCache()
public RangeCache(RangeCache.Weighter<Value> weighter, RangeCache.TimestampExtractor<Value> timestampExtractor)
weighter - a custom weighter to compute the size of each stored valuepublic boolean put(Key key, Value value)
key - value - ref counted value with at least 1 ref to pass on the cachepublic Collection<Value> getRange(Key first, Key last)
first - the first key in the rangelast - the last key in the range (inclusive)public org.apache.commons.lang3.tuple.Pair<Integer,Long> removeRange(Key first, Key last, boolean lastInclusive)
first - last - lastInclusive - public org.apache.commons.lang3.tuple.Pair<Integer,Long> evictLeastAccessedEntries(long minSize)
minSize - public long evictLEntriesBeforeTimestamp(long maxTimestamp)
maxTimestamp - the max timestamp of the entries to be evictedprotected long getNumberOfEntries()
public long getSize()
public long clear()
Copyright © 2017–2022 Apache Software Foundation. All rights reserved.