com.caucho.util
Class LongKeyClockCache<E extends ClockCacheItem>

java.lang.Object
  extended by com.caucho.util.LongKeyClockCache<E>

public class LongKeyClockCache<E extends ClockCacheItem>
extends java.lang.Object

Cache with a clock replacement policy.

Null keys are not allowed. LruCache is synchronized.


Constructor Summary
LongKeyClockCache(int initialCapacity)
          Create the clock cache with a specific capacity.
 
Method Summary
 void clear()
          Clears the cache
 E get(long key)
          Get an item from the cache and make it most recently used.
 E put(long key, E value)
          Puts a new item in the cache.
 ClockCacheItem remove(long key)
          Removes an item from the cache
 int size()
          Returns the current number of entries in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongKeyClockCache

public LongKeyClockCache(int initialCapacity)
Create the clock cache with a specific capacity.

Parameters:
initialCapacity - minimum capacity of the cache
Method Detail

size

public int size()
Returns the current number of entries in the cache.


clear

public void clear()
Clears the cache


get

public E get(long 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 E put(long key,
             E 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 ClockCacheItem remove(long key)
Removes an item from the cache

Parameters:
key - the key to remove
Returns:
the value removed