|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.cafesoft.core.util.LruCache
Implements a "Least Recently Used" object cache. The cache is limited to a configureable maxiumum number of objects, which are accessible by key. If a new object is added to the cache, but the cache is full, then the least recently used object is removed and the new one is added.
| Constructor Summary | |
LruCache(int maxSize)
Creates a new LruCache. |
|
| Method Summary | |
Object |
add(String key,
Object newObject)
Add a cached object. |
void |
clear()
Clear the cache. |
void |
dump(PrintStream out)
Dump the LruCache to the specified PrintStream. |
Object |
get(String key)
Get a cached object by key. |
int |
getMaxSize()
Get the maxium cache size. |
int |
getSize()
Get the current cache size. |
Iterator |
keys()
Get an Iterator of all keys in the cache. |
static void |
main(String[] arg)
Test a LruCache. |
Object |
remove(String key)
Remove a cached object by key. |
Iterator |
values()
Get an Iterator of all values in the cache. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public LruCache(int maxSize)
maxSize - the maxiumum size of the cache| Method Detail |
public int getMaxSize()
public int getSize()
public Object get(String key)
If the object is cached, it becomes the "Most Recently Used" object.
key - The key by which the cached object is hashed.
public Iterator keys()
public Iterator values()
public Object add(String key,
Object newObject)
The newly added object becomes the "most recently used".
key - the key by which the cached object is hashed.newObject - the object to be newly cached.
public Object remove(String key)
key - the key associated with the cached object.
public void clear()
References to cached objects are removed.
public void dump(PrintStream out)
out - the PrintSteam.public static void main(String[] arg)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||