public class CacheEntry<V>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CacheEntry.UpdateException |
| Constructor and Description |
|---|
CacheEntry() |
CacheEntry(V value) |
| Modifier and Type | Method and Description |
|---|---|
void |
expire() |
long |
getCreatedMillis() |
V |
getValue() |
static <K,V> V |
getValue(java.util.concurrent.ConcurrentMap<K,CacheEntry<V>> map,
K key,
long timeoutMillis,
java.util.concurrent.Callable<V> updater) |
static <K,V> V |
getValue(java.util.concurrent.ConcurrentMap<K,CacheEntry<V>> map,
K key,
long timeoutMillis,
java.util.concurrent.Callable<V> updater,
boolean returnExpiredWhileUpdating) |
static <K,V> V |
getValue(java.util.concurrent.ConcurrentMap<K,CacheEntry<V>> map,
K key,
long timeoutMillis,
java.util.concurrent.Callable<V> updater,
java.util.concurrent.Callable<? extends CacheEntry> cacheEntryFactory,
boolean returnExpiredWhileUpdating,
java.lang.Object cacheRequestObject)
Gets a value from cache.
|
V |
getValue(long timeout,
java.util.concurrent.Callable<V> updater) |
V |
getValue(long timeout,
java.util.concurrent.Callable<V> updater,
boolean returnExpiredWhileUpdating,
java.lang.Object cacheRequestObject)
gets the current value from the entry and updates it if it's older than timeout
updater is a callback for creating an updated value.
|
protected V |
getValueWhileUpdating(java.lang.Object cacheRequestObject) |
protected boolean |
hasExpired(long timeout,
java.lang.Object cacheRequestObject) |
boolean |
isInitialized() |
protected void |
resetTimestamp(boolean updated) |
void |
setInitialized(boolean initialized) |
void |
setValue(V val) |
protected boolean |
shouldUpdate(long beforeLockingCreatedMillis,
java.lang.Object cacheRequestObject) |
protected V |
updateValue(V oldValue,
java.util.concurrent.Callable<V> updater,
java.lang.Object cacheRequestObject) |
public CacheEntry()
public CacheEntry(V value)
public static <K,V> V getValue(java.util.concurrent.ConcurrentMap<K,CacheEntry<V>> map, K key, long timeoutMillis, java.util.concurrent.Callable<V> updater, java.util.concurrent.Callable<? extends CacheEntry> cacheEntryFactory, boolean returnExpiredWhileUpdating, java.lang.Object cacheRequestObject)
map - the cache mapkey - the key to look uptimeoutMillis - cache entry timeoutupdater - callback to create/update valuecacheEntryClass - CacheEntry implementation class to usereturnExpiredWhileUpdating - when true, return expired value while updating new valuecacheRequestObject - context object that gets passed to hasExpired, shouldUpdate and updateValue methods, not used in default implementationpublic static <K,V> V getValue(java.util.concurrent.ConcurrentMap<K,CacheEntry<V>> map, K key, long timeoutMillis, java.util.concurrent.Callable<V> updater)
public static <K,V> V getValue(java.util.concurrent.ConcurrentMap<K,CacheEntry<V>> map, K key, long timeoutMillis, java.util.concurrent.Callable<V> updater, boolean returnExpiredWhileUpdating)
public V getValue(long timeout, java.util.concurrent.Callable<V> updater, boolean returnExpiredWhileUpdating, java.lang.Object cacheRequestObject)
timeout - updater - returnExpiredWhileUpdating - cacheRequestObject - protected V getValueWhileUpdating(java.lang.Object cacheRequestObject)
protected V updateValue(V oldValue, java.util.concurrent.Callable<V> updater, java.lang.Object cacheRequestObject) throws java.lang.Exception
java.lang.Exceptionpublic V getValue()
public void setValue(V val)
protected boolean hasExpired(long timeout,
java.lang.Object cacheRequestObject)
protected boolean shouldUpdate(long beforeLockingCreatedMillis,
java.lang.Object cacheRequestObject)
protected void resetTimestamp(boolean updated)
public long getCreatedMillis()
public void expire()
public boolean isInitialized()
public void setInitialized(boolean initialized)