K - the key type.V - the value type.public class DefaultMemoryValueManager<K,V> extends Object implements ValueManager<K,V>
| Constructor and Description |
|---|
DefaultMemoryValueManager()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
AbstractValueWrapper<K,V> |
constructWrapper(K key,
V value)
Construct a ValueWrapper for the value, but do not sets the value, this is done either in "restore" or "storeValue"
|
void |
flush()
This is ensures that any memory data that needs to be persisted is flushed.
|
Logger |
getLogger()
A logger for getting metrics on how the caching is performing.
|
boolean |
isPersisted()
Determine if the values is in a persistence storage.
|
int |
removeAll()
Remove all persisted values from the value "storage".
|
void |
removeValue(AbstractValueWrapper<K,V> valueWrapper)
Removes the value
|
void |
restore(LRUCachingMap<K,V> map)
Restores any persisted key/values to the LRUCachingMap when the map is constructed.
|
V |
retrieveValue(AbstractValueWrapper<K,V> valueWrapper)
Retrives value via the data contained in the ValueWrapper
|
void |
storeValue(AbstractValueWrapper<K,V> valueWrapper,
K key,
V value,
Date expireDateTime)
Stores the value and giving the ValueWrapper enough information to retrieve/remove it again.
|
void |
updateExpireTime(AbstractValueWrapper<K,V> valueWrapper,
Date expireDateTime)
Update the expiration date time for a value.
|
public final void restore(LRUCachingMap<K,V> map)
ValueManagerrestore in interface ValueManager<K,V>map - the map instance.LRUCachingMap.restoreCacheElement(Object, AbstractValueWrapper, Date),
PersistencesRestoreMethod,
AbstractPersistenceValueManager,
ValueManager.flush()public final boolean isPersisted()
ValueManagerisPersisted in interface ValueManager<K,V>true if value is stored in a persistence storage an can be recovered after "reboot", otherwise false.public AbstractValueWrapper<K,V> constructWrapper(K key, V value)
ValueManagerconstructWrapper in interface ValueManager<K,V>key - the keyvalue - the valueValueManager.restore(LRUCachingMap),
ValueManager.storeValue(AbstractValueWrapper, Object, Object, Date)public void storeValue(AbstractValueWrapper<K,V> valueWrapper, K key, V value, Date expireDateTime) throws RuntimeException
ValueManagerstoreValue in interface ValueManager<K,V>valueWrapper - the wrapper instance to store the value or information about the value, this can be used to minimize the memory footprint.key - the keyvalue - the valueexpireDateTime - the expiration datetime for the key, this can be stored on a persisted key/value and used in case of a restore.RuntimeException - if for any reason the value could not be store.public void removeValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManagerremoveValue in interface ValueManager<K,V>RuntimeException - if for any reason the value could not be removed.public V retrieveValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManagerretrieveValue in interface ValueManager<K,V>valueWrapper - theRuntimeException - if for any reason the value could not be retrieved.public void updateExpireTime(AbstractValueWrapper<K,V> valueWrapper, Date expireDateTime) throws RuntimeException
ValueManagerupdateExpireTime in interface ValueManager<K,V>valueWrapper - the wrapper which holds enough information to get the value.expireDateTime - the new expireDateTimeRuntimeException - if this for any reasons fails.public final int removeAll()
ValueManagerremoveAll in interface ValueManager<K,V>public void flush()
flush in interface ValueManager<K,V>LRUCachingMap.cleanup(),
ValueManager.restore(LRUCachingMap)public Logger getLogger()
ValueManagergetLogger in interface ValueManager<K,V>Copyright © 2016. All rights reserved.