com.opensymphony.oscache.base.algorithm
Class FIFOCache
java.lang.Object
java.util.AbstractMap
com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache
com.opensymphony.oscache.base.algorithm.FIFOCache
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Map, java.io.Serializable
- 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: 1.1 $
- Author:
- Mike Cannon-Brookes, Alain Bergevin, Chris Miller
- See Also:
- Serialized Form
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, log, 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(java.lang.Object key)
An object was put in the cache. |
protected void |
itemRemoved(java.lang.Object key)
Remove specified key since that object has been removed from the cache. |
protected void |
itemRetrieved(java.lang.Object key)
An object was retrieved from the cache. |
protected java.lang.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, getGroupsForReading, getMaxEntries, getPersistenceListener, getTableForReading, isEmpty, isMemoryCaching, isUnlimitedDiskCache, keys, keySet, loadFactor, persistClear, persistRemove, persistRemoveGroup, persistRetrieve, persistRetrieveGroup, persistStore, persistStoreGroup, put, putAll, readObject, recordModification, rehash, remove, setMaxEntries, setMemoryCaching, setPersistenceListener, setUnlimitedDiskCache, size, sput, sremove, values, writeObject |
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 |
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.
itemRetrieved
protected void itemRetrieved(java.lang.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(java.lang.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 java.lang.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(java.lang.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.