|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.util.ExpiringReference<T>
public class ExpiringReference<T>
Provides a simple way of tracking a resource that should become stale after a certain time period. This is useful for caching data that was expensive to compute and should be cached for some time before being recreated.
Note: the data will not be unreferenced and thus garbage
collectable until it has been requested at least once after it has expired.
Thus expiring references must be combined with an LRUHashMap if
memory conservation is also desired.
| Field Summary | |
|---|---|
protected long |
_expires
|
protected T |
_value
|
| Constructor Summary | |
|---|---|
ExpiringReference(T value,
long expireMillis)
Creates an reference to the specified value that will expire in the specified number of milliseconds. |
|
| Method Summary | ||
|---|---|---|
static
|
create(T value,
long expireMillis)
Creates an expiring reference with the supplied value and expiration time. |
|
static
|
get(ExpiringReference<T> value)
Gets the value from an expiring reference but returns null if the supplied reference reference is null. |
|
T |
getValue()
Returns the value with which we were created or null if the value has expired. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected T _value
protected long _expires
| Constructor Detail |
|---|
public ExpiringReference(T value,
long expireMillis)
| Method Detail |
|---|
public static <T> ExpiringReference<T> create(T value,
long expireMillis)
public static <T> T get(ExpiringReference<T> value)
public T getValue()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||