com.opensymphony.oscache.plugins.diskpersistence
Class HashDiskPersistenceListener
java.lang.Object
com.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener
com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener
- All Implemented Interfaces:
- PersistenceListener, Serializable
public class HashDiskPersistenceListener
- extends AbstractDiskPersistenceListener
Persists cache data to disk. Provides a hash of the standard key name as the file name.
A configurable hash algorithm is used to create a digest of the cache key for the
disk filename. This is to allow for more sane filenames for objects which dont generate
friendly cache keys.
- Author:
- Jason Parrott
- See Also:
- Serialized Form
Methods inherited from class com.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener |
adjustFileCachePath, clear, getCacheFile, getCachePath, getContextTmpDir, getRoot, initFileCaching, isGroupStored, isStored, remove, remove, removeGroup, retrieve, retrieveGroup, store, store, storeGroup |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HASH_ALGORITHM_KEY
public static final String HASH_ALGORITHM_KEY
- See Also:
- Constant Field Values
DEFAULT_HASH_ALGORITHM
public static final String DEFAULT_HASH_ALGORITHM
- See Also:
- Constant Field Values
md
protected MessageDigest md
HashDiskPersistenceListener
public HashDiskPersistenceListener()
configure
public PersistenceListener configure(Config config)
- Initializes the HashDiskPersistenceListener. Namely this involves only setting up the
message digester to hash the key values.
- Specified by:
configure
in interface PersistenceListener
- Overrides:
configure
in class AbstractDiskPersistenceListener
- Parameters:
config
- The OSCache configuration- See Also:
PersistenceListener.configure(com.opensymphony.oscache.base.Config)
getCacheFileName
protected char[] getCacheFileName(String key)
- Generates a file name for the given cache key. In this case the file name is attempted to be
generated from the hash of the standard key name. Cache algorithm is configured via the
cache.persistence.disk.hash.algorithm configuration variable.
- Specified by:
getCacheFileName
in class AbstractDiskPersistenceListener
- Parameters:
key
- cache entry key
- Returns:
- char[] file name