org.apache.turbine.util
Class BufferCache

java.lang.Object
  extended byorg.apache.commons.collections.SequencedHashMap
      extended byorg.apache.turbine.util.BufferCache
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, java.util.Map, java.io.Serializable

public class BufferCache
extends org.apache.commons.collections.SequencedHashMap

A fixed length object cache implementing the LRU algorithm. Convenient for buffering recently used objects.

Version:
$Id: BufferCache.java 278822 2005-09-05 19:53:05Z henning $
Author:
Daniel Rall, Henning P. Schmiedehausen
See Also:
Serialized Form

Constructor Summary
BufferCache()
          Creates a new instance with default storage buffer pre-allocated.
BufferCache(int maxSize)
          Creates a new instance with the specified storage buffer pre-allocated.
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Retrieves the value associated with the provided key, freshening the sequence of the key as well.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Stores the provided key/value pair, freshening its list index if the specified key already exists.
 
Methods inherited from class org.apache.commons.collections.SequencedHashMap
clear, clone, containsKey, containsValue, entrySet, equals, get, getFirst, getFirstKey, getFirstValue, getLast, getLastKey, getLastValue, getValue, hashCode, indexOf, isEmpty, iterator, keySet, lastIndexOf, putAll, readExternal, remove, remove, sequence, size, toString, values, writeExternal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferCache

public BufferCache()
Creates a new instance with default storage buffer pre-allocated.


BufferCache

public BufferCache(int maxSize)
Creates a new instance with the specified storage buffer pre-allocated.

Parameters:
maxSize - The maximum size of the cache.
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Stores the provided key/value pair, freshening its list index if the specified key already exists.

Parameters:
key - The key to the provided value.
value - The value to store.
Returns:
The previous value for the specified key, or null if none.

get

public java.lang.Object get(java.lang.Object key)
Retrieves the value associated with the provided key, freshening the sequence of the key as well.

Parameters:
key - The key whose value to retrieve.
Returns:
The keyed value.


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.