K
- the key type.V
- the value type.public abstract class AbstractFileValueManager<K,V> extends AbstractPersistenceValueManager<K,V>
PersistencesRestoreMethod.NONE
: No restore is performed. Files is left in the caching directory.PersistencesRestoreMethod.DELETE_ALL
: Deleting all the files in the caching directory and sub directories if stated.PersistencesRestoreMethod.LOAD_ALL
: Load all files from the caching directory and sub directories. The next cleanup handles the cache.PersistencesRestoreMethod.LOAD_WITHIN_EXPIRETIME
: Load all files from the caching directory and sub directories where "File.lastModified" is below "new Date().getTime() + expireTime".File.lastModified()
,
LRUCachingMapConfiguration.getExpireTime()
,
CachingDirectory.isRecursive()
Constructor and Description |
---|
AbstractFileValueManager(CachingDirectory cachingDirectory,
PersistencesRestoreMethod persistencesRestoreMethod)
Constructor - see class description.
|
Modifier and Type | Method and Description |
---|---|
DefaultFileValueWrapper<K,V> |
cast(AbstractValueWrapper<K,V> valueWrapper)
A convience method that cast the "AbstractValueWrapper" to a "DefaultFileValueWrapper"
|
abstract File |
constructFile(K key,
V value)
Constructs a file using the Key and Value.
|
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"
|
CachingDirectory |
getCachingDirectory()
The directory to store the Value as a file.
|
File |
getFile(AbstractValueWrapper<K,V> valueWrapper)
Gets the file where the value is stored.
|
abstract 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
|
void |
restore(LRUCachingMap<K,V> map)
Restores any persisted key/values to the LRUCachingMap when the map is constructed.
|
void |
updateExpireTime(AbstractValueWrapper<K,V> valueWrapper,
Date expireDateTime)
Update the expiration date time for a value.
|
getLogger, getPersistencesRestoreMethod, isPersisted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flush, retrieveValue, storeValue
public AbstractFileValueManager(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
.CachingDirectory.validate()
public final CachingDirectory getCachingDirectory()
public final void restore(LRUCachingMap<K,V> map)
ValueManager
map
- the map instance.LRUCachingMap.restoreCacheElement(Object, AbstractValueWrapper, Date)
,
PersistencesRestoreMethod
,
AbstractPersistenceValueManager
,
ValueManager.flush()
public AbstractValueWrapper<K,V> constructWrapper(K key, V value)
ValueManager
key
- the keyvalue
- the valueValueManager.restore(LRUCachingMap)
,
ValueManager.storeValue(AbstractValueWrapper, Object, Object, Date)
public void removeValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManager
RuntimeException
- if for any reason the value could not be removed.public int removeAll()
ValueManager
public final void updateExpireTime(AbstractValueWrapper<K,V> valueWrapper, Date expireDateTime)
ValueManager
valueWrapper
- the wrapper which holds enough information to get the value.expireDateTime
- the new expireDateTimepublic final DefaultFileValueWrapper<K,V> cast(AbstractValueWrapper<K,V> valueWrapper)
valueWrapper
- AbstractValueWrapperpublic final File getFile(AbstractValueWrapper<K,V> valueWrapper)
valueWrapper
- the which is a (DefaultFileValueWrapper)public abstract K reconstructKey(File file)
file
- the file.Copyright © 2016. All rights reserved.