public class LruEvictionPolicy<K,V> extends Object implements EvictionPolicy<K,V>, LruEvictionPolicyMBean, Externalizable
Least Recently Used (LRU) algorithm. 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.| 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()
Gets current queue size.
|
int |
getMaxSize()
Gets maximum allowed size of cache before entry will start getting evicted.
|
void |
onEntryAccessed(boolean rmv,
EvictableEntry<K,V> entry)
Callback for whenever entry is accessed.
|
Collection<EvictableEntry<K,V>> |
queue()
Gets read-only view on internal
FIFO queue in proper order. |
void |
readExternal(ObjectInput in) |
void |
setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
public LruEvictionPolicy()
public LruEvictionPolicy(int max)
max - Maximum allowed size of cache before entry will start getting evicted.public int getMaxSize()
getMaxSize in interface LruEvictionPolicyMBeanpublic void setMaxSize(int max)
setMaxSize in interface LruEvictionPolicyMBeanmax - Maximum allowed size of cache before entry will start getting evicted.public int getCurrentSize()
getCurrentSize in interface LruEvictionPolicyMBeanpublic Collection<EvictableEntry<K,V>> queue()
FIFO queue in proper order.'FIFO' queue.public void onEntryAccessed(boolean rmv,
EvictableEntry<K,V> entry)
onEntryAccessed in interface EvictionPolicy<K,V>rmv - True if entry has been removed, false otherwise.entry - Accessed entry.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundException
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0 Release Date : March 31 2015