pnuts.lang
Class Cache

java.lang.Object
  |
  +--pnuts.lang.Cache
Direct Known Subclasses:
RefCache

public class Cache
extends java.lang.Object

An implementation of LRU cache


Constructor Summary
protected Cache()
           
  Cache(int size)
           
  Cache(int size, boolean compareID)
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          If key is in the cache it returns value, otherwise null.
 void put(java.lang.Object key, java.lang.Object value)
          Register key and its value into the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

protected Cache()

Cache

public Cache(int size)
Parameters:
size - cache size

Cache

public Cache(int size,
             boolean compareID)
Parameters:
size - cache size
compareID - If true keys are compared by their object IDs, otherwise by Object.equals().
Method Detail

get

public java.lang.Object get(java.lang.Object key)
If key is in the cache it returns value, otherwise null.

put

public void put(java.lang.Object key,
                java.lang.Object value)
Register key and its value into the cache.