K
- the key type.V
- the value type.public abstract class AbstractKeyedFileValueManager<K,V extends Keyed<K>> extends AbstractFileValueManager<K,V>
Constructor and Description |
---|
AbstractKeyedFileValueManager(CachingDirectory cachingDirectory,
PersistencesRestoreMethod persistencesRestoreMethod)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
File |
constructFile(K key,
V value)
Constructs a file using the Key and Value.
|
void |
flush()
This is ensures that any memory data that needs to be persisted is flushed.
|
K |
reconstructKey(File file)
When restoring a persisted LRUCachingMap, we need the ability to reconstruct the Key.
|
abstract V |
retrieveFileValue(DefaultFileValueWrapper<K,V> valueWrapper)
Loads the value from the file in valueWrapper.
|
V |
retrieveValue(AbstractValueWrapper<K,V> valueWrapper)
Retrives value via the data contained in the ValueWrapper
|
abstract void |
storeFileValue(DefaultFileValueWrapper<K,V> valueWrapper,
K key,
V value)
This method shall the take the Value and stored it in a file given by 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.
|
cast, constructWrapper, getCachingDirectory, getFile, removeAll, removeValue, restore, updateExpireTime
getLogger, getPersistencesRestoreMethod, isPersisted
public AbstractKeyedFileValueManager(CachingDirectory cachingDirectory, PersistencesRestoreMethod persistencesRestoreMethod) throws IllegalArgumentException, NullPointerException
cachingDirectory
- the directory where to store the cached values.persistencesRestoreMethod
- the restore method, when reconstructing the LRUCachingMap.IllegalArgumentException
- if cachingDirectory isnt a valid directory.NullPointerException
- if persistencesRestoreMethod or cachingDirectory is null
.public void storeValue(AbstractValueWrapper<K,V> valueWrapper, K key, V value, Date expireDateTime) throws RuntimeException
ValueManager
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 V retrieveValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManager
valueWrapper
- theRuntimeException
- if for any reason the value could not be retrieved.public K reconstructKey(File file)
AbstractFileValueManager
reconstructKey
in class AbstractFileValueManager<K,V extends Keyed<K>>
file
- the file.public File constructFile(K key, V value)
AbstractFileValueManager
constructFile
in class AbstractFileValueManager<K,V extends Keyed<K>>
key
- the keyvalue
- the valuepublic void flush()
public abstract void storeFileValue(DefaultFileValueWrapper<K,V> valueWrapper, K key, V value) throws RuntimeException
valueWrapper
- the value wrapper which holds the file.key
- the key.value
- the value.RuntimeException
- if the value can not be stored in the file.public abstract V retrieveFileValue(DefaultFileValueWrapper<K,V> valueWrapper)
valueWrapper
- the value wrapperCopyright © 2016. All rights reserved.