|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javatools.util.Cache
General purpose cache class. Acts basically like a weak reference dictionary except that it also returns null when asked to find an item whose use-by date has expired. It works with two main data structures: A Dictionary which provides fast access into the cache, and a Queue which keeps track of the least recently used items in the cache so that old items can be removed and limit the cache to a bounded size.
Nested Class Summary | |
(package private) class |
Cache.CacheItem
This is the class we store in our internal data structures. |
Constructor Summary | |
Cache()
|
|
Cache(int size)
Constructor which takes an initial guesstimate of how many items we expect to store in it |
Method Summary | |
void |
expire(java.lang.Object key)
Expire the item in the cache with the given key. |
java.lang.Object |
get(java.lang.Object key)
Get an object from the cache. |
void |
put(java.lang.Object key,
java.lang.Object item)
Put a key value pair into the cache. |
void |
setCacheMaxAgeSeconds(int s)
Change the maximum age of items in the cache. |
void |
setCacheMaxObj(int n)
Set the maximum number of objects to cache. |
void |
setNoCacheMaxAge()
Turn off cache expiry based on age |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Cache()
public Cache(int size)
size
- Description of ParameterMethod Detail |
public void setCacheMaxObj(int n)
n
- The new cacheMaxObj valuepublic void setCacheMaxAgeSeconds(int s)
s
- The new cacheMaxAgeSeconds valuepublic void setNoCacheMaxAge()
public java.lang.Object get(java.lang.Object key)
key
- Description of Parameter
public void put(java.lang.Object key, java.lang.Object item)
key
- Description of Parameteritem
- Description of Parameterpublic void expire(java.lang.Object key)
key
- Description of Parameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |