dynaop.util
Class Cache

java.lang.Object
  extended bydynaop.util.Cache

public abstract class Cache
extends java.lang.Object

Cache with weak keys and soft values.

Author:
Bob Lee (crazybob@crazybob.org)

Constructor Summary
Cache()
          Defaults to weak keys.
Cache(boolean weakKeys)
          Creates cache.
 
Method Summary
protected abstract  java.lang.Object create(java.lang.Object key)
          Creates value for key.
 java.lang.Object get(java.lang.Object key)
          Gets value for key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache(boolean weakKeys)
Creates cache.

Parameters:
weakKeys - Use weak references for keys.

Cache

public Cache()
Defaults to weak keys.

Method Detail

create

protected abstract java.lang.Object create(java.lang.Object key)
Creates value for key. Called by getter if value isn't cached.


get

public java.lang.Object get(java.lang.Object key)
Gets value for key. Creates if necessary.