|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.cache.eviction.lirs.GridCacheLirsEvictionPolicy<K,V>
public class GridCacheLirsEvictionPolicy<K,V>
Very efficient implementation of LIRS cache eviction policy which often provides
better hit ratio than the LRU eviction policy. It in particular offers much better
performance for access patterns with weak locality, such as regular access over more
entries than the cache size. Instead of standard LRU eviction based on
access order, LIRS maintains a main LRU stack, called LIRS Stack,
as primary Low Inter-reference Recency stack, and a secondary queue, called
HIRS Queue) for High Inter-Reference recency entries.
Note that this implementation is extremely efficient as it is essentially lock-contention-free and does not create any additional table-like data structures. For more information see Low Inter-Reference Recency Set (LIRS) algorithm by Sone Jiang and Xiaodong Zhang.
| Wiki | |
| Forum |
![]() |
![]() |
![]() |
![]() |
| Field Summary | |
|---|---|
static float |
DFLT_QUEUE_SIZE_RATIO
Default ratio of HIRS (High Inter-reference Recency Set). |
| Constructor Summary | |
|---|---|
GridCacheLirsEvictionPolicy()
Constructs LIRS eviction policy with all defaults. |
|
GridCacheLirsEvictionPolicy(int max)
Constructs LIRS eviction policy with maximum size. |
|
GridCacheLirsEvictionPolicy(int max,
boolean allowEmptyEntries)
Constructs LIRS eviction policy with maximum size and specified allow empty entries flag. |
|
GridCacheLirsEvictionPolicy(int max,
float queueRatio)
Constructs LIRS eviction policy with maximum size and secondary queue ratio to compute size of secondary queue. |
|
GridCacheLirsEvictionPolicy(int max,
float queueRatio,
boolean allowEmptyEntries)
Constructs LIRS eviction policy with maximum size and secondary queue ratio to compute size of secondary queue. |
|
| Method Summary | |
|---|---|
int |
getCurrentQueueSize()
Gets current HIRS queue size. |
int |
getCurrentStackSize()
Gets current main stack size. |
int |
getMaxQueueSize()
Gets maximum allowed size of HIRS queue before entries will start getting evicted. |
int |
getMaxSize()
Gets maximum allowed cache size. |
int |
getMaxStackSize()
Gets maximum allowed size of main stack This value is computed based on GridCacheLirsEvictionPolicyMBean.getQueueSizeRatio() value. |
String |
getMetaAttributeName()
Gets name of metadata attribute used to store eviction policy data. |
double |
getQueueSizeRatio()
Gets ratio for HIRS queue size relative to main stack size. |
boolean |
isAllowEmptyEntries()
Gets flag indicating whether empty entries (entries with null values)
are allowed. |
void |
onEntryAccessed(boolean rmv,
GridCacheEntry<K,V> entry)
Callback for whenever entry is accessed. |
Collection<GridCacheEntry<K,V>> |
queue()
Gets read-only view on secondary HIR queue to hold High Inter-reference Recency
entries. |
void |
setAllowEmptyEntries(boolean allowEmptyEntries)
Sets flag that allows empty entries (entries with null values)
to be stored in cache. |
void |
setMaxSize(int max)
Sets maximum allowed size of cached entries. |
void |
setQueueSizeRatio(double queueRatio)
Sets ratio of HIRS queue size compared to main stack size. |
Collection<GridCacheEntry<K,V>> |
stack()
Gets read-only view on main internal stack for LIRS implementation. |
String |
toFullString()
Gets string representation of all queue and stack contents. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final float DFLT_QUEUE_SIZE_RATIO
HIRS (High Inter-reference Recency Set). Default value is 0.02,
which means that HIRS set size is 2% of LIRS set size.
| Constructor Detail |
|---|
public GridCacheLirsEvictionPolicy()
public GridCacheLirsEvictionPolicy(int max)
max - Maximum allowed size of entries in cache.
public GridCacheLirsEvictionPolicy(int max,
boolean allowEmptyEntries)
max - Maximum allowed size of entries in cache.allowEmptyEntries - If false, empty entries will be evicted immediately.
public GridCacheLirsEvictionPolicy(int max,
float queueRatio)
max - Maximum allowed size of entries in cache.queueRatio - Ratio of HIRS queue size compared to maximum allowed size.
public GridCacheLirsEvictionPolicy(int max,
float queueRatio,
boolean allowEmptyEntries)
max - Maximum allowed size of entries in cache.queueRatio - Ratio of HIRS queue size compared to maximum allowed size.allowEmptyEntries - If false, empty entries will be evicted immediately.| Method Detail |
|---|
public int getMaxSize()
getMaxSize in interface GridCacheLirsEvictionPolicyMBeanpublic void setMaxSize(int max)
setMaxSize in interface GridCacheLirsEvictionPolicyMBeanmax - Maximum allowed size of cached entries.public boolean isAllowEmptyEntries()
null values)
are allowed.
isAllowEmptyEntries in interface GridCacheLirsEvictionPolicyMBeanTrue if empty entries are allowed, false otherwise.public void setAllowEmptyEntries(boolean allowEmptyEntries)
null values)
to be stored in cache.
setAllowEmptyEntries in interface GridCacheLirsEvictionPolicyMBeanallowEmptyEntries - If false, empty entries will be evicted immediately.public double getQueueSizeRatio()
HIRS queue size relative to main stack size.
getQueueSizeRatio in interface GridCacheLirsEvictionPolicyMBeanHIRS queue size relative to main stack size.public String getMetaAttributeName()
getMetaAttributeName in interface GridCacheLirsEvictionPolicyMBeanpublic void setQueueSizeRatio(double queueRatio)
HIRS queue size compared to main stack size. Generally HIRS
size should be much smaller than main stack size. The default value is 0.02
defined by GridCacheLirsEvictionPolicy.DFLT_QUEUE_SIZE_RATIO constant.
queueRatio - Ratio of HIRS set size compared to main stack size.public int getMaxQueueSize()
HIRS queue before entries will start getting evicted.
This value is computed based on GridCacheLirsEvictionPolicyMBean.getQueueSizeRatio() value.
getMaxQueueSize in interface GridCacheLirsEvictionPolicyMBeanHIRS queue before entries will start getting evicted.public int getMaxStackSize()
GridCacheLirsEvictionPolicyMBean.getQueueSizeRatio() value.
getMaxStackSize in interface GridCacheLirsEvictionPolicyMBeanpublic int getCurrentStackSize()
GridCacheLirsEvictionPolicyMBean
getCurrentStackSize in interface GridCacheLirsEvictionPolicyMBeanpublic int getCurrentQueueSize()
GridCacheLirsEvictionPolicyMBeanHIRS queue size.
getCurrentQueueSize in interface GridCacheLirsEvictionPolicyMBeanpublic Collection<GridCacheEntry<K,V>> stack()
LIRS implementation.
LIRS implementation.public Collection<GridCacheEntry<K,V>> queue()
HIR queue to hold High Inter-reference Recency
entries.
HIR 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.public String toFullString()
public String toString()
toString in class Object
|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Real Time Big Data
|
|
|