com.opensymphony.oscache.base.persistence
Interface PersistenceListener

All Known Implementing Classes:
AbstractDiskPersistenceListener, DiskPersistenceListener, HashDiskPersistenceListener

public interface PersistenceListener

Defines the methods that are required to persist cache data. To provide a custom persistence mechanism you should implement this interface and supply the fully-qualified classname to the cache via the cache.persistence.class configuration property.

Version:
$Revision: 254 $
Author:
Francois Beauregard

Method Summary
 void clear()
          Clear the entire persistent cache (including the root)
 PersistenceListener configure(Config config)
          Allow the persistence code to initialize itself based on the supplied cache configuration.
 boolean isGroupStored(String groupName)
          Verify if a group is currently stored in the persistent cache.
 boolean isStored(String key)
          Verify if an object is currently stored in the persistent cache.
 void remove(String key)
          Removes an object from the persistent cache
 void removeGroup(String groupName)
          Removes a group from the persistent cache.
 Object retrieve(String key)
          Retrieves an object from the persistent cache.
 Set retrieveGroup(String groupName)
          Retrieves a group from the persistent cache.
 void store(String key, Object obj)
          Stores an object in the persistent cache.
 void storeGroup(String groupName, Set group)
          Stores a group in the persistent cache.
 

Method Detail

isStored

boolean isStored(String key)
                 throws CachePersistenceException
Verify if an object is currently stored in the persistent cache.

Parameters:
key - The cache key of the object to check.
Throws:
CachePersistenceException

isGroupStored

boolean isGroupStored(String groupName)
                      throws CachePersistenceException
Verify if a group is currently stored in the persistent cache.

Parameters:
groupName - The name of the group to check.
Throws:
CachePersistenceException

clear

void clear()
           throws CachePersistenceException
Clear the entire persistent cache (including the root)

Throws:
CachePersistenceException

configure

PersistenceListener configure(Config config)
Allow the persistence code to initialize itself based on the supplied cache configuration.


remove

void remove(String key)
            throws CachePersistenceException
Removes an object from the persistent cache

Throws:
CachePersistenceException

removeGroup

void removeGroup(String groupName)
                 throws CachePersistenceException
Removes a group from the persistent cache.

Parameters:
groupName - The name of the cache group to remove.
Throws:
CachePersistenceException

retrieve

Object retrieve(String key)
                throws CachePersistenceException
Retrieves an object from the persistent cache.

Parameters:
key - The unique cache key that maps to the object being retrieved.
Returns:
The object, or null if no object was found matching the supplied key.
Throws:
CachePersistenceException

store

void store(String key,
           Object obj)
           throws CachePersistenceException
Stores an object in the persistent cache.

Parameters:
key - The key to uniquely identify this object.
obj - The object to persist. Most implementations of this interface will require this object implements Serializable.
Throws:
CachePersistenceException

storeGroup

void storeGroup(String groupName,
                Set group)
                throws CachePersistenceException
Stores a group in the persistent cache.

Parameters:
groupName - The name of the group to persist.
group - A set containing the keys of all the CacheEntry objects that belong to this group.
Throws:
CachePersistenceException

retrieveGroup

Set retrieveGroup(String groupName)
                  throws CachePersistenceException
Retrieves a group from the persistent cache.

Parameters:
groupName - The name of the group to retrieve.
Returns:
The returned set should contain the keys of all the CacheEntry objects that belong to this group.
Throws:
CachePersistenceException

OSCache Project Page