Package org.apache.jackrabbit.oak.cache
Class CacheLIRS.Builder<K,V>
- java.lang.Object
-
- org.apache.jackrabbit.oak.cache.CacheLIRS.Builder<K,V>
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CacheLIRS.Builder<K,V>
averageWeight(int averageWeight)
Set the average weight of an entry.CacheLIRS<K,V>
build()
CacheLIRS<K,V>
build(CacheLoader<K,V> cacheLoader)
CacheLIRS.Builder<K,V>
evictionCallback(CacheLIRS.EvictionCallback<K,V> evicted)
CacheLIRS.Builder<K,V>
maximumSize(long maxSize)
Set the maximum size (in number of entries).CacheLIRS.Builder<K,V>
maximumWeight(long maxWeight)
Set the total maximum weight.CacheLIRS.Builder<K,V>
module(java.lang.String module)
CacheLIRS.Builder<K,V>
recordStats()
CacheLIRS.Builder<K,V>
segmentCount(int segmentCount)
CacheLIRS.Builder<K,V>
stackMoveDistance(int stackMoveDistance)
How many other item are to be moved to the top of the stack before the current item is moved.CacheLIRS.Builder<K,V>
weigher(Weigher<K,V> weigher)
Set the weigher which is used if memory usage of an entry is not explicitly set (when adding entries).
-
-
-
Method Detail
-
recordStats
public CacheLIRS.Builder<K,V> recordStats()
-
module
public CacheLIRS.Builder<K,V> module(java.lang.String module)
-
weigher
public CacheLIRS.Builder<K,V> weigher(Weigher<K,V> weigher)
Set the weigher which is used if memory usage of an entry is not explicitly set (when adding entries).- Parameters:
weigher
- the weigher- Returns:
- this
-
maximumWeight
public CacheLIRS.Builder<K,V> maximumWeight(long maxWeight)
Set the total maximum weight. If the cache is heavier, then entries are evicted.- Parameters:
maxWeight
- the maximum weight- Returns:
- this
-
averageWeight
public CacheLIRS.Builder<K,V> averageWeight(int averageWeight)
Set the average weight of an entry. This is used, together with the maximum weight, to calculate the length of the internal array of the cache. For higher performance, the weight should be set relatively low, at the cost of some space. To save space, the average weight should be set high, at the cost of some performance.- Parameters:
averageWeight
- the average weight- Returns:
- this
-
maximumSize
public CacheLIRS.Builder<K,V> maximumSize(long maxSize)
Set the maximum size (in number of entries). This is the same as setting the average weight of an entry to 1, and the maximum weight to the maximum size.- Parameters:
maxSize
- the maximum size- Returns:
- this
-
segmentCount
public CacheLIRS.Builder<K,V> segmentCount(int segmentCount)
-
stackMoveDistance
public CacheLIRS.Builder<K,V> stackMoveDistance(int stackMoveDistance)
How many other item are to be moved to the top of the stack before the current item is moved. The default is 16. Using higher values will avoid re-ordering in many cases, so less time is spent reordering. But this somewhat reduces cache hit rate, and eviction will become more random. Typically, cache hit rate can be improved by using smaller values, and access performance can be improved using larger values. Using values larger than 128 is not recommended.
-
evictionCallback
public CacheLIRS.Builder<K,V> evictionCallback(CacheLIRS.EvictionCallback<K,V> evicted)
-
-