public class LruEvictionPolicy<K,V> extends AbstractEvictionPolicy<K,V> implements IgniteMBeanAware
Least Recently Used (LRU)
algorithm and supports batch eviction.
The eviction starts in the following cases:
batchSize
elements greater than the maximum size.maxMemSize == 0
).
batchSize
elements will be evicted in this case. The default batchSize
value is 1
.
This implementation is very efficient since it is lock-free and does not create any additional table-like
data structures. The LRU
ordering information is maintained by attaching ordering metadata to cache entries.memSize
Constructor and Description |
---|
LruEvictionPolicy()
Constructs LRU eviction policy with all defaults.
|
LruEvictionPolicy(int max)
Constructs LRU eviction policy with maximum size.
|
Modifier and Type | Method and Description |
---|---|
int |
getCurrentSize() |
Object |
getMBean() |
Collection<EvictableEntry<K,V>> |
queue()
Gets read-only view on internal
FIFO queue in proper order. |
protected boolean |
removeMeta(Object meta) |
LruEvictionPolicy<K,V> |
setBatchSize(int batchSize)
Sets batch size.
|
LruEvictionPolicy<K,V> |
setMaxMemorySize(long maxMemSize)
Sets maximum allowed cache size in bytes.
|
LruEvictionPolicy<K,V> |
setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.
|
protected int |
shrink0()
Tries to remove one item from queue.
|
String |
toString() |
protected boolean |
touch(EvictableEntry<K,V> entry) |
getBatchSize, getCurrentMemorySize, getMaxMemorySize, getMaxSize, onEntryAccessed, readExternal, shrink, writeExternal
public LruEvictionPolicy()
public LruEvictionPolicy(int max)
max
- Maximum allowed size of cache before entry will start getting evicted.public int getCurrentSize()
getCurrentSize
in class AbstractEvictionPolicy<K,V>
public LruEvictionPolicy<K,V> setMaxMemorySize(long maxMemSize)
setMaxMemorySize
in class AbstractEvictionPolicy<K,V>
this
for chaining.public LruEvictionPolicy<K,V> setMaxSize(int max)
setMaxSize
in class AbstractEvictionPolicy<K,V>
max
- Maximum allowed size of cache before entry will start getting evicted.this
for chaining.public LruEvictionPolicy<K,V> setBatchSize(int batchSize)
setBatchSize
in class AbstractEvictionPolicy<K,V>
batchSize
- Batch size.this
for chaining.public Collection<EvictableEntry<K,V>> queue()
FIFO
queue in proper order.'FIFO'
queue.protected boolean removeMeta(Object meta)
removeMeta
in class AbstractEvictionPolicy<K,V>
meta
- Meta-information shipped to an entry.True
if meta was successfully removed from the container.protected boolean touch(EvictableEntry<K,V> entry)
touch
in class AbstractEvictionPolicy<K,V>
entry
- Entry to touch.True
if new node has been added to queue by this call.protected int shrink0()
shrink0
in class AbstractEvictionPolicy<K,V>
-1
if queue is empty.public Object getMBean()
getMBean
in interface IgniteMBeanAware
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024