com.opensymphony.oscache.base.algorithm
Class FIFOCache

java.lang.Object
  extended by java.util.AbstractMap
      extended by com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache
          extended by com.opensymphony.oscache.base.algorithm.FIFOCache
All Implemented Interfaces:
Serializable, Cloneable, Map

public class FIFOCache
extends AbstractConcurrentReadCache

FIFO (First In First Out) based queue algorithm for the cache. No synchronization is required in this class since the AbstractConcurrentReadCache already takes care of any synchronization requirements.

Version:
$Revision: 427 $
Author:
Mike Cannon-Brookes, Alain Bergevin, Chris Miller
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache
AbstractConcurrentReadCache.Entry, AbstractConcurrentReadCache.HashIterator, AbstractConcurrentReadCache.KeyIterator, AbstractConcurrentReadCache.ValueIterator
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
private  Collection list
          A queue containing all cache keys
private static long serialVersionUID
           
 
Fields inherited from class com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache
barrierLock, count, DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_MAX_ENTRIES, entrySet, groups, keySet, lastWrite, loadFactor, maxEntries, memoryCaching, NULL, persistenceListener, table, threshold, UNLIMITED, unlimitedDiskCache, values
 
Constructor Summary
FIFOCache()
          Constructs a FIFO Cache.
FIFOCache(int capacity)
          Constructs a FIFO Cache of the specified capacity.
 
Method Summary
protected  void itemPut(Object key)
          An object was put in the cache.
protected  void itemRemoved(Object key)
          Remove specified key since that object has been removed from the cache.
protected  void itemRetrieved(Object key)
          An object was retrieved from the cache.
protected  Object removeItem()
          An item needs to be removed from the cache.
 
Methods inherited from class com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache
capacity, clear, clone, contains, containsKey, containsValue, elements, entrySet, findAndRemoveEntry, get, getGroup, getGroupForReading, getGroupsForReading, getMaxEntries, getPersistenceListener, getTableForReading, isEmpty, isMemoryCaching, isOverflowPersistence, isUnlimitedDiskCache, keys, keySet, loadFactor, persistClear, persistRemove, persistRemoveGroup, persistRetrieve, persistRetrieveGroup, persistStore, persistStoreGroup, put, putAll, recordModification, rehash, remove, removeForce, setMaxEntries, setMemoryCaching, setOverflowPersistence, setPersistenceListener, setUnlimitedDiskCache, size, sput, sremove, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

list

private Collection list
A queue containing all cache keys

Constructor Detail

FIFOCache

public FIFOCache()
Constructs a FIFO Cache.


FIFOCache

public FIFOCache(int capacity)
Constructs a FIFO Cache of the specified capacity.

Parameters:
capacity - The maximum cache capacity.
Method Detail

itemRetrieved

protected void itemRetrieved(Object key)
An object was retrieved from the cache. This implementation does noting since this event has no impact on the FIFO algorithm.

Specified by:
itemRetrieved in class AbstractConcurrentReadCache
Parameters:
key - The cache key of the item that was retrieved.

itemPut

protected void itemPut(Object key)
An object was put in the cache. This implementation just adds the key to the end of the list if it doesn't exist in the list already.

Specified by:
itemPut in class AbstractConcurrentReadCache
Parameters:
key - The cache key of the item that was put.

removeItem

protected Object removeItem()
An item needs to be removed from the cache. The FIFO implementation removes the first element in the list (ie, the item that has been in the cache for the longest time).

Specified by:
removeItem in class AbstractConcurrentReadCache
Returns:
The key of whichever item was removed.

itemRemoved

protected void itemRemoved(Object key)
Remove specified key since that object has been removed from the cache.

Specified by:
itemRemoved in class AbstractConcurrentReadCache
Parameters:
key - The cache key of the item that was removed.


Copyright © 2011 OpenSymphony. All Rights Reserved.