V - type of data in the cache entry.public class CacheEntry<V> extends Object implements Serializable
This entry contains the actual data to be cached and an expiration token.
The expiration token is used internally by the SelfLoadingCache to
decide if the entry needs to be updated. This allows to update che cache entry
asynchronously while the cache keep serving the stored data.
| Modifier | Constructor and Description |
|---|---|
protected |
CacheEntry()
Default constructor.
|
protected |
CacheEntry(V value,
Instant expiration)
Constructor with parameters.
|
protected |
CacheEntry(V value,
long expiration)
Constructor with parameters.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
Instant |
getExpiration()
Returns the instant in time when the cache entry expires.
|
V |
getValue()
Returns the cached value.
|
int |
hashCode() |
boolean |
isExpired()
Tells if the cache entry is expired.
|
static <V> CacheEntry<V> |
of(V value,
Instant expiration)
Creates a new
CacheEntry with the given value and duration. |
static <V> CacheEntry<V> |
of(V value,
long expiration)
Creates a new
CacheEntry with the given value and duration. |
String |
toString() |
protected CacheEntry()
This constructor is intended to be used by reflection during de-serialization.
To create a new cache entry use the factory methods.
protected CacheEntry(V value, long expiration)
This constructor is intended to be used by extending classes only.
To create a new cache entry use the factory methods.
value - value to be cached.expiration - Unix Timestamp (in milliseconds) that tells when the entry expires.protected CacheEntry(V value, Instant expiration)
This constructor is intended to be used by extending classes only.
To create a new cache entry use the factory methods.
value - value to be cached.expiration - instant in time when the cache entry expires.public static <V> CacheEntry<V> of(V value, long expiration)
CacheEntry with the given value and duration.V - type of the value to put into cache.value - the value to put into cache.expiration - Unix Timestamp (in milliseconds) when the entry expires.CacheEntry with the given value and duration.public static <V> CacheEntry<V> of(V value, Instant expiration)
CacheEntry with the given value and duration.
The value can also be null while the expiration instant
must be not null
V - type of the value to put into cache.value - the value to put into cache.expiration - instant in time when the cache entry expires.CacheEntry with the given value and duration.public V getValue()
public Instant getExpiration()
public boolean isExpired()
true if the cache entry is expired.Copyright © 2011–2020 Nerd4j. All rights reserved.