public class GridCacheLruEvictionPolicy<K,V> extends Object implements GridCacheEvictionPolicy<K,V>, GridCacheLruEvictionPolicyMBean
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 |
|---|
GridCacheLruEvictionPolicy()
Constructs LRU eviction policy with all defaults.
|
GridCacheLruEvictionPolicy(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.
|
String |
getMetaAttributeName()
Gets name of metadata attribute used to store eviction policy data.
|
void |
onEntryAccessed(boolean rmv,
GridCacheEntry<K,V> entry)
Callback for whenever entry is accessed.
|
Collection<GridCacheEntry<K,V>> |
queue()
Gets read-only view on internal
FIFO queue in proper order. |
void |
setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.
|
String |
toString() |
public GridCacheLruEvictionPolicy()
public GridCacheLruEvictionPolicy(int max)
max - Maximum allowed size of cache before entry will start getting evicted.public int getMaxSize()
getMaxSize in interface GridCacheLruEvictionPolicyMBeanpublic void setMaxSize(int max)
setMaxSize in interface GridCacheLruEvictionPolicyMBeanmax - Maximum allowed size of cache before entry will start getting evicted.public int getCurrentSize()
getCurrentSize in interface GridCacheLruEvictionPolicyMBeanpublic String getMetaAttributeName()
getMetaAttributeName in interface GridCacheLruEvictionPolicyMBeanpublic Collection<GridCacheEntry<K,V>> queue()
FIFO queue in proper order.'FIFO' queue.public void onEntryAccessed(boolean rmv,
GridCacheEntry<K,V> entry)
onEntryAccessed in interface GridCacheEvictionPolicy<K,V>rmv - True if entry has been removed, false otherwise.entry - Accessed entry.Copyright © 2014. All rights reserved.