|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.opensymphony.oscache.plugins.diskpersistence.AbstractDiskPersistenceListener
public abstract class AbstractDiskPersistenceListener
Persist the cache data to disk. The code in this class is totally not thread safe it is the resonsibility of the cache using this persistence listener to handle the concurrency.
| Field Summary | |
|---|---|
protected static java.lang.String |
APPLICATION_CACHE_SUBPATH
Sub path name for application cache |
protected static java.lang.String |
CACHE_EXTENSION
File extension for disk cache file |
static java.lang.String |
CACHE_PATH_KEY
|
protected static java.lang.String |
CONTEXT_TMPDIR
Property to get the temporary working directory of the servlet container. |
protected static java.lang.String |
GROUP_DIRECTORY
The directory that cache groups are stored under |
protected static java.lang.String |
SESSION_CACHE_SUBPATH
Sub path name for session cache |
| Constructor Summary | |
|---|---|
AbstractDiskPersistenceListener()
|
|
| Method Summary | |
|---|---|
protected java.lang.String |
adjustFileCachePath(java.lang.String cachePathStr)
Allows to translate to the temp dir of the servlet container if cachePathStr is javax.servlet.context.tempdir. |
void |
clear()
Clears the whole cache directory, starting from the root |
PersistenceListener |
configure(Config config)
Initialises this DiskPersistenceListener using the supplied configuration. |
protected java.io.File |
getCacheFile(java.lang.String key)
Build fully qualified cache file for the specified cache entry key. |
protected abstract char[] |
getCacheFileName(java.lang.String key)
Build cache file name for the specified cache entry key. |
java.io.File |
getCachePath()
Get the physical cache path on disk. |
java.io.File |
getContextTmpDir()
Get the servlet context tmp directory. |
java.lang.String |
getRoot()
Get the root directory for persisting the cache on disk. |
protected void |
initFileCaching(java.lang.String cachePathStr)
Set caching to file on or off. |
boolean |
isGroupStored(java.lang.String group)
Verify if a group exists in the cache |
boolean |
isStored(java.lang.String key)
Verify if an object is currently stored in the cache |
protected void |
remove(java.io.File file)
|
void |
remove(java.lang.String key)
Delete a single cache entry. |
void |
removeGroup(java.lang.String groupName)
Deletes an entire group from the cache. |
java.lang.Object |
retrieve(java.lang.String key)
Retrieve an object from the disk |
java.util.Set |
retrieveGroup(java.lang.String groupName)
Retrieves a group from the cache, or null if the group
file could not be found. |
protected void |
store(java.io.File file,
java.lang.Object obj)
Stores an object using the supplied file object |
void |
store(java.lang.String key,
java.lang.Object obj)
Stores an object in cache |
void |
storeGroup(java.lang.String groupName,
java.util.Set group)
Stores a group in the persistent cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CACHE_PATH_KEY
protected static final java.lang.String CACHE_EXTENSION
protected static final java.lang.String GROUP_DIRECTORY
protected static final java.lang.String APPLICATION_CACHE_SUBPATH
protected static final java.lang.String SESSION_CACHE_SUBPATH
protected static final java.lang.String CONTEXT_TMPDIR
| Constructor Detail |
|---|
public AbstractDiskPersistenceListener()
| Method Detail |
|---|
public java.io.File getCachePath()
public java.lang.String getRoot()
public java.io.File getContextTmpDir()
public boolean isGroupStored(java.lang.String group)
throws CachePersistenceException
isGroupStored in interface PersistenceListenergroup - The group name to check
CachePersistenceException
public boolean isStored(java.lang.String key)
throws CachePersistenceException
isStored in interface PersistenceListenerkey - The object key
CachePersistenceException
public void clear()
throws CachePersistenceException
clear in interface PersistenceListenerCachePersistenceExceptionpublic PersistenceListener configure(Config config)
configure in interface PersistenceListenerconfig - The OSCache configuration
public void remove(java.lang.String key)
throws CachePersistenceException
remove in interface PersistenceListenerkey - The object key to delete
CachePersistenceException
public void removeGroup(java.lang.String groupName)
throws CachePersistenceException
removeGroup in interface PersistenceListenergroupName - The name of the group to delete
CachePersistenceException
public java.lang.Object retrieve(java.lang.String key)
throws CachePersistenceException
retrieve in interface PersistenceListenerkey - The object key
CachePersistenceException
public java.util.Set retrieveGroup(java.lang.String groupName)
throws CachePersistenceException
null if the group
file could not be found.
retrieveGroup in interface PersistenceListenergroupName - The name of the group to retrieve.
Set containing keys of all of the cache
entries that belong to this group.
CachePersistenceException
public void store(java.lang.String key,
java.lang.Object obj)
throws CachePersistenceException
store in interface PersistenceListenerkey - The object's keyobj - The object to store
CachePersistenceException
public void storeGroup(java.lang.String groupName,
java.util.Set group)
throws CachePersistenceException
storeGroup in interface PersistenceListenergroupName - The name of the group to persist.group - A set containing the keys of all the CacheEntry
objects that belong to this group.
CachePersistenceExceptionprotected java.lang.String adjustFileCachePath(java.lang.String cachePathStr)
cachePathStr - Cache path read from the properties file.
protected void initFileCaching(java.lang.String cachePathStr)
cache.path property exists, we assume file caching is turned on.
By the same token, to turn off file caching just remove this property.
protected void remove(java.io.File file)
throws CachePersistenceException
CachePersistenceException
protected void store(java.io.File file,
java.lang.Object obj)
throws CachePersistenceException
file - The file to use for storing the objectobj - the object to store
CachePersistenceExceptionprotected java.io.File getCacheFile(java.lang.String key)
key - Cache Entry Key.
protected abstract char[] getCacheFileName(java.lang.String key)
key - Cache Entry Key.
|
OSCache Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||