public class FifoEvictionPolicy<K,V> extends AbstractEvictionPolicy<K,V> implements IgniteMBeanAware
First In First Out (FIFO)
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 does not create any additional
table-like data structures. The FIFO
ordering information is
maintained by attaching ordering metadata to cache entries.
memSize
Constructor and Description |
---|
FifoEvictionPolicy()
Constructs FIFO eviction policy with all defaults.
|
FifoEvictionPolicy(int max)
Constructs FIFO eviction policy with maximum size.
|
FifoEvictionPolicy(int max,
int batchSize)
Constructs FIFO eviction policy with maximum size and given batch 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) |
FifoEvictionPolicy<K,V> |
setBatchSize(int batchSize)
Sets batch size.
|
FifoEvictionPolicy<K,V> |
setMaxMemorySize(long maxMemSize)
Sets maximum allowed cache size in bytes.
|
FifoEvictionPolicy<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 FifoEvictionPolicy()
public FifoEvictionPolicy(int max)
max
- Maximum allowed size of cache before entry will start getting evicted.public FifoEvictionPolicy(int max, int batchSize)
max
- Maximum allowed size of cache before entry will start getting evicted.batchSize
- Batch size.public int getCurrentSize()
getCurrentSize
in class AbstractEvictionPolicy<K,V>
public FifoEvictionPolicy<K,V> setMaxMemorySize(long maxMemSize)
setMaxMemorySize
in class AbstractEvictionPolicy<K,V>
maxMemSize
- Maximum allowed cache size in bytes.this
for chaining.public FifoEvictionPolicy<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 FifoEvictionPolicy<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 queue has been changed by this call.protected int shrink0()
shrink0
in class AbstractEvictionPolicy<K,V>
-1
if queue is empty.public Object getMBean()
getMBean
in interface IgniteMBeanAware
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023