Each object is associated with a maximum time to live (TTL) after which it is removed from the cache and a time "extension" (each time the object is accessed the minimal time it stays in the cache is extended by the extension period). So the minimum time an object stays in the cache is the "extension" period, the maximum time is the TTL. Every now and then a "garbage collector" wipes "dead" objects out of the cache - independently of if they are still stored or not "dead" objects will never be accessible and be treated like being already wiped out.
Public Member Functions | |
| Cache () | |
| Cache (long ttl) | |
| Cache (long ttl, long extension) | |
| Cache (long ttl, long extension, long gcInterval) | |
| void | add (Object key, Object contents) |
| void | add (Object key, Object contents, long ttl) |
| void | add (Object key, Object contents, long ttl, long extension) |
| void | gc () |
| Object | get (Object key) |
| void | remove (Object key) |
| int | size () |
| Enumeration | elements () |
Package Attributes | |
| Hashtable | cache = new Hashtable() |
| long | ttl |
| long | extension |
| long | gcInterval |
| long | nextGc = 0 |
| Thread | gcRunning = null |
Classes | |
| class | CacheObject |
|
|
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.4.5