|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.oscache.plugins.diskpersistence.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 String |
APPLICATION_CACHE_SUBPATH
Sub path name for application cache |
protected static String |
CACHE_EXTENSION
File extension for disk cache file |
static String |
CACHE_PATH_KEY
|
protected static String |
CONTEXT_TMPDIR
Property to get the temporary working directory of the servlet container. |
protected static String |
GROUP_DIRECTORY
The directory that cache groups are stored under |
protected static String |
SESSION_CACHE_SUBPATH
Sub path name for session cache |
Constructor Summary | |
AbstractDiskPersistenceListener()
|
Method Summary | |
protected String |
adjustFileCachePath(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 File |
getCacheFile(String key)
Build fully qualified cache file for the specified cache entry key. |
protected abstract char[] |
getCacheFileName(String key)
Build cache file name for the specified cache entry key. |
File |
getCachePath()
Get the physical cache path on disk. |
File |
getContextTmpDir()
Get the servlet context tmp directory. |
String |
getRoot()
Get the root directory for persisting the cache on disk. |
protected void |
initFileCaching(String cachePathStr)
Set caching to file on or off. |
boolean |
isGroupStored(String group)
Verify if a group exists in the cache |
boolean |
isStored(String key)
Verify if an object is currently stored in the cache |
protected void |
remove(File file)
|
void |
remove(String key)
Delete a single cache entry. |
void |
removeGroup(String groupName)
Deletes an entire group from the cache. |
Object |
retrieve(String key)
Retrieve an object from the disk |
Set |
retrieveGroup(String groupName)
Retrieves a group from the cache, or null if the group
file could not be found. |
protected void |
store(File file,
Object obj)
Stores an object using the supplied file object |
void |
store(String key,
Object obj)
Stores an object in cache |
void |
storeGroup(String groupName,
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 String CACHE_PATH_KEY
protected static final String CACHE_EXTENSION
protected static final String GROUP_DIRECTORY
protected static final String APPLICATION_CACHE_SUBPATH
protected static final String SESSION_CACHE_SUBPATH
protected static final String CONTEXT_TMPDIR
Constructor Detail |
public AbstractDiskPersistenceListener()
Method Detail |
public File getCachePath()
public String getRoot()
public File getContextTmpDir()
public boolean isGroupStored(String group) throws CachePersistenceException
isGroupStored
in interface PersistenceListener
group
- The group name to check
CachePersistenceException
public boolean isStored(String key) throws CachePersistenceException
isStored
in interface PersistenceListener
key
- The object key
CachePersistenceException
public void clear() throws CachePersistenceException
clear
in interface PersistenceListener
CachePersistenceException
public PersistenceListener configure(Config config)
configure
in interface PersistenceListener
config
- The OSCache configurationpublic void remove(String key) throws CachePersistenceException
remove
in interface PersistenceListener
key
- The object key to delete
CachePersistenceException
public void removeGroup(String groupName) throws CachePersistenceException
removeGroup
in interface PersistenceListener
groupName
- The name of the group to delete
CachePersistenceException
public Object retrieve(String key) throws CachePersistenceException
retrieve
in interface PersistenceListener
key
- The object key
CachePersistenceException
public Set retrieveGroup(String groupName) throws CachePersistenceException
null
if the group
file could not be found.
retrieveGroup
in interface PersistenceListener
groupName
- 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(String key, Object obj) throws CachePersistenceException
store
in interface PersistenceListener
key
- The object's keyobj
- The object to store
CachePersistenceException
public void storeGroup(String groupName, Set group) throws CachePersistenceException
storeGroup
in interface PersistenceListener
groupName
- The name of the group to persist.group
- A set containing the keys of all the CacheEntry
objects that belong to this group.
CachePersistenceException
protected String adjustFileCachePath(String cachePathStr)
cachePathStr
- Cache path read from the properties file.
protected void initFileCaching(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(File file) throws CachePersistenceException
CachePersistenceException
protected void store(File file, Object obj) throws CachePersistenceException
file
- The file to use for storing the objectobj
- the object to store
CachePersistenceException
protected File getCacheFile(String key)
key
- Cache Entry Key.
protected abstract char[] getCacheFileName(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 |