org.knopflerfish.util
public class CachedObject<V> extends java.lang.Object
A CachedObject has a timeout period - during that period the get
method will return the stored object, afterwards get will
return null
CacheMap| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_TIMEOUT
Default timeout period in milliseconds.
|
| Constructor and Description |
|---|
CachedObject()
Equivalent to
CachedObject(null). |
CachedObject(V object)
Equivalent to
CachedObject(object, CachedObject.DEFAULT_TIMEOUT) |
CachedObject(V object,
long timeout)
Create a cached object from an object and a specified timeout.
|
| Modifier and Type | Method and Description |
|---|---|
void |
flush()
Clear the stored object.
|
V |
get()
Get the cached object.
|
void |
set(V object)
Set the cache's object and restore its creation time.
|
java.lang.String |
toString()
Print the cached object as "<object's string value>:<remaining
time in milliseconds>"
|
public static final long DEFAULT_TIMEOUT
public CachedObject()
CachedObject(null).CacheMappublic CachedObject(V object)
CachedObject(object, CachedObject.DEFAULT_TIMEOUT)DEFAULT_TIMEOUTpublic CachedObject(V object, long timeout)
object - Object to cachetimeout - period in milliseconds.DEFAULT_TIMEOUTpublic void set(V object)
object - Object to cachepublic V get()
null
afterwards.public void flush()
get willpublic java.lang.String toString()
toString in class java.lang.Object