GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.cache.eviction.fifo
Class GridCacheFifoEvictionPolicy<K,V>

java.lang.Object
  extended by org.gridgain.grid.cache.eviction.fifo.GridCacheFifoEvictionPolicy<K,V>
All Implemented Interfaces:
GridCacheFifoEvictionPolicyMBean, GridCacheEvictionPolicy<K,V>

public class GridCacheFifoEvictionPolicy<K,V>
extends Object
implements GridCacheEvictionPolicy<K,V>, GridCacheFifoEvictionPolicyMBean

Eviction policy based on First In First Out (FIFO) algorithm. This implementation is very efficient since it is lock-free and does not create any additional table-like data structures. The FIFO ordering information is maintained by attaching ordering metadata to cache entries.

Wiki & Forum:


Wiki
Forum

 

Constructor Summary
GridCacheFifoEvictionPolicy()
          Constructs LRU eviction policy with all defaults.
GridCacheFifoEvictionPolicy(int max)
          Constructs FIFO eviction policy with maximum size.
GridCacheFifoEvictionPolicy(int max, boolean allowEmptyEntries)
          Constructs FIFO eviction policy with maximum size and allow empty entries flag specified.
 
Method Summary
 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.
 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 internal FIFO queue in proper order.
 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 cache before entry will start getting evicted.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridCacheFifoEvictionPolicy

public GridCacheFifoEvictionPolicy()
Constructs LRU eviction policy with all defaults.


GridCacheFifoEvictionPolicy

public GridCacheFifoEvictionPolicy(int max)
Constructs FIFO eviction policy with maximum size. Empty entries are allowed.

Parameters:
max - Maximum allowed size of cache before entry will start getting evicted.

GridCacheFifoEvictionPolicy

public GridCacheFifoEvictionPolicy(int max,
                                   boolean allowEmptyEntries)
Constructs FIFO eviction policy with maximum size and allow empty entries flag specified.

Parameters:
max - Maximum allowed size of cache before entry will start getting evicted.
allowEmptyEntries - If false, false empty entries will be evicted immediately.
Method Detail

getMaxSize

public int getMaxSize()
Gets maximum allowed size of cache before entry will start getting evicted.

Specified by:
getMaxSize in interface GridCacheFifoEvictionPolicyMBean
Returns:
Maximum allowed size of cache before entry will start getting evicted.

setMaxSize

public void setMaxSize(int max)
Sets maximum allowed size of cache before entry will start getting evicted.

Specified by:
setMaxSize in interface GridCacheFifoEvictionPolicyMBean
Parameters:
max - Maximum allowed size of cache before entry will start getting evicted.

isAllowEmptyEntries

public boolean isAllowEmptyEntries()
Gets flag indicating whether empty entries (entries with null values) are allowed.

Specified by:
isAllowEmptyEntries in interface GridCacheFifoEvictionPolicyMBean
Returns:
True if empty entries are allowed, false otherwise.

setAllowEmptyEntries

public void setAllowEmptyEntries(boolean allowEmptyEntries)
Sets flag that allows empty entries (entries with null values) to be stored in cache.

Specified by:
setAllowEmptyEntries in interface GridCacheFifoEvictionPolicyMBean
Parameters:
allowEmptyEntries - If false, empty entries will be evicted immediately.

getCurrentSize

public int getCurrentSize()
Gets current queue size.

Specified by:
getCurrentSize in interface GridCacheFifoEvictionPolicyMBean
Returns:
Current queue size.

getMetaAttributeName

public String getMetaAttributeName()
Gets name of metadata attribute used to store eviction policy data.

Specified by:
getMetaAttributeName in interface GridCacheFifoEvictionPolicyMBean
Returns:
Name of metadata attribute used to store eviction policy data.

queue

public Collection<GridCacheEntry<K,V>> queue()
Gets read-only view on internal FIFO queue in proper order.

Returns:
Read-only view ono internal 'FIFO' queue.

onEntryAccessed

public void onEntryAccessed(boolean rmv,
                            GridCacheEntry<K,V> entry)
Callback for whenever entry is accessed.

Specified by:
onEntryAccessed in interface GridCacheEvictionPolicy<K,V>
Parameters:
rmv - True if entry has been removed, false otherwise.
entry - Accessed entry.

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube