com.caucho.util
Class FlatCache

java.lang.Object
  |
  +--com.caucho.util.FlatCache

public class FlatCache
extends java.lang.Object

Fixed length cache with a LRU replacement policy. If cache items implement CacheListener, they will be informed when they're removed from the cache.

Null keys are not allowed. LruCache is synchronized.


Constructor Summary
FlatCache(int initialCapacity)
           
 
Method Summary
 void clear()
          Clears the cache
 java.lang.Object get(java.lang.Object key)
          Get an item from the cache and make it most recently used.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Puts a new item in the cache.
 java.lang.Object remove(java.lang.Object key)
          Removes an item from the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlatCache

public FlatCache(int initialCapacity)
Method Detail

clear

public void clear()
Clears the cache

get

public java.lang.Object get(java.lang.Object key)
Get an item from the cache and make it most recently used.
Parameters:
key - key to lookup the item
Returns:
the matching object in the cache

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Puts a new item in the cache. If the cache is full, remove the LRU item.
Parameters:
key - key to store data
value - value to be stored
Returns:
old value stored under the key

remove

public java.lang.Object remove(java.lang.Object key)
Removes an item from the cache
Parameters:
key - the key to remove
Returns:
the value removed