org.jcreme.caches
Class FIFOCache

java.lang.Object
  extended byorg.jcreme.caches.BaseCache
      extended byorg.jcreme.caches.HashCache
          extended byorg.jcreme.caches.FIFOCache
All Implemented Interfaces:
Cache

public class FIFOCache
extends HashCache

The FIFO cache is based on a First In First Out algorithm to select the objects that are removed from the cache to make room. This implementation uses a LinkedList.

Version:
$Revision: 1.2 $
Author:
$Author: dbregeon $

Constructor Summary
FIFOCache()
          Creates new LIFOCache
FIFOCache(int minSize, int maxSize)
          Creates new LIFOCache
 
Method Summary
 void clear()
          Removes all the objects from the Cache, leaving it empty.
 void registerObject(java.lang.Object key, java.lang.Object value)
          This method adds an object in the cache.
protected  void removeOneElement()
          This method is called when room is needed to add a new object in the cache.
 void unregisterObject(java.lang.Object key)
          This method removes an object from the cache.
 
Methods inherited from class org.jcreme.caches.HashCache
getAllObjects, getAllObjects, getMap, getObject, getSize, registerAllObjects
 
Methods inherited from class org.jcreme.caches.BaseCache
addCacheListener, buildEvent, fireElementAdded, fireElementRemoved, getCacheListeners, getMaxSize, getMinSize, getReplacementPolicy, removeCacheListener, setMaxSize, setReplacementPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FIFOCache

public FIFOCache()
Creates new LIFOCache


FIFOCache

public FIFOCache(int minSize,
                 int maxSize)
Creates new LIFOCache

Parameters:
minSize - the initial size of the Cache.
maxSize - the maximum number of objects contained by the cache.
Method Detail

registerObject

public void registerObject(java.lang.Object key,
                           java.lang.Object value)
                    throws CacheFullException
This method adds an object in the cache.

Specified by:
registerObject in interface Cache
Overrides:
registerObject in class HashCache
Parameters:
key - the key that will be used to retrieve the object.
value - the object to store in the cache.
Throws:
CacheFullException - if the object could not be stored in the cache.

unregisterObject

public void unregisterObject(java.lang.Object key)
This method removes an object from the cache.

Specified by:
unregisterObject in interface Cache
Overrides:
unregisterObject in class HashCache
Parameters:
key - the key that was used to store the object in the cache.

clear

public void clear()
Removes all the objects from the Cache, leaving it empty.

Specified by:
clear in interface Cache
Overrides:
clear in class HashCache

removeOneElement

protected void removeOneElement()
This method is called when room is needed to add a new object in the cache.



Copyright 2006 null. All Rights Reserved.