02/28/2005
 

com.vignette.portal.cache
Class FirstInFirstOutStrategy

java.lang.Object
  |
  +--com.vignette.portal.cache.CacheStrategy
        |
        +--com.vignette.portal.cache.ActionBasedCacheStrategy
              |
              +--com.vignette.portal.cache.SizeBasedStrategy
                    |
                    +--com.vignette.portal.cache.FirstInFirstOutStrategy

public abstract class FirstInFirstOutStrategy
extends SizeBasedStrategy

Removes the oldest entries from the cache when the cache's size is being exceeded.

This strategy only records the order in which keys are added to the cache and therefore incurs very little overhead.


Constructor Summary
FirstInFirstOutStrategy(CacheAction action, int sizeOfCache)
          Creates a cache of specified size with specified action logic.
FirstInFirstOutStrategy(int sizeOfCache)
          Creates a cache of specified size with default action logic.
 
Method Summary
 void onAdd(Object key, Object value, Map properties)
          Signals addition to the cache.
 void onGet(Object key, Map properties)
          Someone is accessing key in the Cache.
 
Methods inherited from class com.vignette.portal.cache.SizeBasedStrategy
getSizeOfCache, onInvalidate, onInvalidateAll, onInvalidateAll, onRemove, onRemoveAll, onRemoveAll
 
Methods inherited from class com.vignette.portal.cache.ActionBasedCacheStrategy
getCacheAction, setStore
 
Methods inherited from class com.vignette.portal.cache.CacheStrategy
getStore, onAddAll, onGetAll, onPut, onPutAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FirstInFirstOutStrategy

public FirstInFirstOutStrategy(int sizeOfCache)

Creates a cache of specified size with default action logic.

Parameters:
sizeOfCache - the maximum number of objects allowed in the cache.
See Also:
SizeBasedStrategy.SizeBasedStrategy(int)

FirstInFirstOutStrategy

public FirstInFirstOutStrategy(CacheAction action,
                               int sizeOfCache)

Creates a cache of specified size with specified action logic.

Parameters:
action - the non-null action to invoke when the size of the cache is exceeded.
sizeOfCache - the maximum number of objects allowed in the cache.
See Also:
SizeBasedStrategy.SizeBasedStrategy(CacheAction, int)
Method Detail

onGet

public void onGet(Object key,
                  Map properties)
           throws CacheException
Description copied from class: CacheStrategy

Someone is accessing key in the Cache.

Individual strategies can use the information in properties to override their creation-time parameters.

Overrides:
onGet in class CacheStrategy
Following copied from class: com.vignette.portal.cache.CacheStrategy
Parameters:
key - item being looked up
properties - possible overrides, can be null

onAdd

public void onAdd(Object key,
                  Object value,
                  Map properties)
Description copied from class: CacheStrategy

Signals addition to the cache. The mapping of key to value is being inserted in the cache and this strategy should start monitoring it, if appropriate for its algorithm.

Individual strategies can use the information in properties to override their creation-time parameters.

This method should not throw any exception since other strategies on the same cache might already have changed their state in response to this signal and the cache will not be able to revert them back to their prior state. The strategies will become out of sync with each other and with the cache, yielding unpredictable behavior.

Perform any validation checks in onPut instead. But note that another strategy could call this method without calling onPut first, in which case there is no way to recover from invalid conditions.

Overrides:
onAdd in class CacheStrategy
Following copied from class: com.vignette.portal.cache.CacheStrategy
Parameters:
key - key being inserted in the cache
value - value being inserted in the cache, matching key
properties - possible overrides, can be null

02/28/2005
 

Copyright and Trademark Notices