public class CacheItem<V>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected long |
expirationTimeNanos |
protected V |
item |
protected @Nullable ShouldDisposeFunc<V> |
shouldDisposeFunc |
| Modifier | Constructor and Description |
|---|---|
protected |
CacheItem(V item,
long expirationTimeNanos)
Constructs a CacheItem.
|
protected |
CacheItem(V item,
long expirationTimeNanos,
@Nullable ShouldDisposeFunc<V> shouldDisposeFunc)
Constructs a CacheItem.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
protected void |
extendExpiration(long timeToLiveNanos)
Renews a cache item's expiration time.
|
int |
hashCode() |
protected boolean |
isExpired()
Indicates whether this item is expired.
|
protected boolean |
shouldCleanup()
Determines if a cache item should be cleaned up.
|
java.lang.String |
toString() |
protected final V item
protected long expirationTimeNanos
protected final @Nullable ShouldDisposeFunc<V> shouldDisposeFunc
protected CacheItem(V item, long expirationTimeNanos)
item - the item value.expirationTimeNanos - the time at which the CacheItem should be considered expired.protected CacheItem(V item, long expirationTimeNanos, @Nullable ShouldDisposeFunc<V> shouldDisposeFunc)
item - the item value.expirationTimeNanos - the time at which the CacheItem should be considered expired.shouldDisposeFunc - a function defining whether an expired item should be disposed. If null, items will
always be disposed when expired.protected boolean isExpired()
protected void extendExpiration(long timeToLiveNanos)
timeToLiveNanos - the duration that the item should sit in the cache before being considered expired, in
nanoseconds.protected boolean shouldCleanup()
ShouldDisposeFunc (if defined) indicates that it should be cleaned up.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object