K - the key type.V - the valye type.public abstract class AbstractIndexedFileValueManager<K extends Serializable,V> extends AbstractFileValueManager<K,V>
| Modifier and Type | Field and Description |
|---|---|
File |
PERSISTENCE_STORAGE_INDEX_FILE |
static String |
PERSISTENCE_STORAGE_INDEX_FILENAME |
| Constructor and Description |
|---|
AbstractIndexedFileValueManager(CachingDirectory cachingDirectory,
PersistencesRestoreMethod persistencesRestoreMethod,
int indexSaveInterval)
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.
|
int |
getIndexSaveInterval()
How many changes must be made before the index "File-to-Key" hashtable is persisted.
|
K |
reconstructKey(File file)
When restoring a persisted LRUCachingMap, we need the ability to reconstruct the Key.
|
int |
removeAll()
Remove all persisted values from the value "storage".
|
void |
removeValue(AbstractValueWrapper<K,V> valueWrapper)
Removes the value
|
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, restore, updateExpireTimegetLogger, getPersistencesRestoreMethod, isPersistedpublic static final String PERSISTENCE_STORAGE_INDEX_FILENAME
public final File PERSISTENCE_STORAGE_INDEX_FILE
public AbstractIndexedFileValueManager(CachingDirectory cachingDirectory, PersistencesRestoreMethod persistencesRestoreMethod, int indexSaveInterval) throws IllegalArgumentException, NullPointerException
cachingDirectory - the directory where to store the cached values.persistencesRestoreMethod - the restore method, when reconstructing the LRUCachingMap.indexSaveInterval - hint for how often many changes must happend before the index is persisted as file.IllegalArgumentException - if cachingDirectory isnt a valid directory.NullPointerException - if persistencesRestoreMethod or cachingDirectory is null.CachingDirectory.validate()public final void storeValue(AbstractValueWrapper<K,V> valueWrapper, K key, V value, Date expireDateTime) throws RuntimeException
ValueManagervalueWrapper - 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 final int removeAll()
ValueManagerremoveAll in interface ValueManager<K extends Serializable,V>removeAll in class AbstractFileValueManager<K extends Serializable,V>public final int getIndexSaveInterval()
public final V retrieveValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManagervalueWrapper - theRuntimeException - if for any reason the value could not be retrieved.public final K reconstructKey(File file)
AbstractFileValueManagerreconstructKey in class AbstractFileValueManager<K extends Serializable,V>file - the file.public final void removeValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManagerremoveValue in interface ValueManager<K extends Serializable,V>removeValue in class AbstractFileValueManager<K extends Serializable,V>RuntimeException - if for any reason the value could not be removed.public final File constructFile(K key, V value)
AbstractFileValueManagerconstructFile in class AbstractFileValueManager<K extends Serializable,V>key - the keyvalue - the valuepublic final 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.