|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Cache
A data cache. This is essentially a wrapper over a collection that allows for objects to be cached for a specified amount of time and expired thereafter. Objects in the cache can expire automatically or can be removed manually.
Method Summary | |
---|---|
void |
clear()
Empties the entire cache by expiring and removing all objects. |
void |
close()
Closes this cache, which makes all items in the cache unavailable. |
boolean |
containsKey(java.lang.Object key)
Returns true if the cache has a valid cached item specified by the key. |
void |
expire(java.lang.Object key)
Expires immediately the object specified by the key. |
void |
extend(java.lang.Object key,
long extendTime)
Adds the specified amount of time to the object (to it's current time left) before that object will be expired. |
java.lang.Object |
get(java.lang.Object key)
Returns the cached item specified by the key. |
java.util.Map |
getAll()
Returns all objects in the cache. |
long |
getDefaultTTL()
Gets the default TTL in milliseconds. |
long |
getTimeLeft(java.lang.Object key)
Returns the amount of time left (in milliseconds) before the object will be expired from the cache. |
boolean |
isClosed()
Returns true if this cache has been closed, false otherwise. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object item)
Convenience method that puts an object into the cache that expires in the default TTL. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object val,
long expiry)
Puts the specified object into the cache, mapped with the specified key. |
void |
setDefaultTTL(long millis)
Sets the default TTL in milliseconds. |
Method Detail |
---|
void clear()
boolean containsKey(java.lang.Object key)
key
- typically a String but can be any objectjava.lang.Object get(java.lang.Object key)
key
- typically a String but can be any objectjava.util.Map getAll()
Modification to this map will affect this cache.
java.lang.Object put(java.lang.Object key, java.lang.Object val, long expiry)
key
- key with which the specified value is to be associated.val
- value to be associated with the specified key.expiry
- time in milliseconds (from the time the
object is put into the cache) before it is expired. Specify
-1 for the item to never expire.java.lang.Object put(java.lang.Object key, java.lang.Object item)
setDefaultTTL(long)
method and subclasses are free to implement a default TTL as they see fit.
If that key already contains a value, then that value is returned by this
method (and also replaced by the new value).
long getTimeLeft(java.lang.Object key)
If the object specified by the key is not found in the cache, then 0 is returned.
If the object has already expired, then 0 is returned.
If the object will never expire, then -1 is returned.
key
- the key with which to find the object under consideration.void expire(java.lang.Object key)
key
- the key with which to find the object under consideration.void extend(java.lang.Object key, long extendTime)
key
- the key with which to find the object
under consideration.extendTime
- exntension time in milliseconds, valid
values are >= 0 and -1void setDefaultTTL(long millis)
long getDefaultTTL()
void close()
boolean isClosed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |