|
|||||||||
| Home >> All >> javatools >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
javatools.util
Class Cache

java.lang.Objectjavatools.util.Cache
- public class Cache
- extends java.lang.Object
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. Modified: 8th March 2003 11:41
- Version:
- 0.1.10
| Nested Class Summary | |
(package private) class |
Cache.CacheItem
This is the class we store in our internal data structures. |
| Field Summary | |
private int |
cacheMaxAge
The maximum age of items in the cache in milliseconds. |
private int |
cacheMaxObj
The maximum number of objects in the cache |
private java.util.Dictionary |
dictionary
The fast access dictionary |
private JQueue |
queue
The lru (least recently used) queue |
| Constructor Summary | |
Cache()
Creates a new Cache object. |
|
Cache(int size)
Constructor which takes an initial guesstimate of how many items we expect to store in it |
|
| Method Summary | |
void |
clear()
|
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 |
| Field Detail |
dictionary
private java.util.Dictionary dictionary
- The fast access dictionary
queue
private JQueue queue
- The lru (least recently used) queue
cacheMaxObj
private int cacheMaxObj
- The maximum number of objects in the cache
cacheMaxAge
private int cacheMaxAge
- The maximum age of items in the cache in milliseconds.
| Constructor Detail |
Cache
public Cache()
- Creates a new Cache object.
Cache
public Cache(int size)
- Constructor which takes an initial guesstimate of how many items we expect
to store in it
| Method Detail |
setCacheMaxObj
public void setCacheMaxObj(int n)
- Set the maximum number of objects to cache.
setCacheMaxAgeSeconds
public void setCacheMaxAgeSeconds(int s)
- Change the maximum age of items in the cache. Can be changed at any time.
setNoCacheMaxAge
public void setNoCacheMaxAge()
- Turn off cache expiry based on age
get
public java.lang.Object get(java.lang.Object key)
- Get an object from the cache. Returns null if the object is not in the
cache.
put
public void put(java.lang.Object key, java.lang.Object item)
- Put a key value pair into the cache.
expire
public void expire(java.lang.Object key)
- Expire the item in the cache with the given key.
clear
public void clear()
|
|||||||||
| Home >> All >> javatools >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
javatools.util.Cache