com.opensymphony.oscache.base.persistence
Interface PersistenceListener


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: 1.1 $
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(java.lang.String groupName)
          Verify if a group is currently stored in the persistent cache.
 boolean isStored(java.lang.String key)
          Verify if an object is currently stored in the persistent cache.
 void remove(java.lang.String key)
          Removes an object from the persistent cache
 void removeGroup(java.lang.String groupName)
          Removes a group from the persistent cache.
 java.lang.Object retrieve(java.lang.String key)
          Retrieves an object from the persistent cache.
 java.util.Set retrieveGroup(java.lang.String groupName)
          Retrieves a group from the persistent cache.
 void store(java.lang.String key, java.lang.Object obj)
          Stores an object in the persistent cache.
 void storeGroup(java.lang.String groupName, java.util.Set group)
          Stores a group in the persistent cache.
 

Method Detail

isStored

public boolean isStored(java.lang.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

public boolean isGroupStored(java.lang.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

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

Throws:
CachePersistenceException

configure

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


remove

public void remove(java.lang.String key)
            throws CachePersistenceException
Removes an object from the persistent cache

Throws:
CachePersistenceException

removeGroup

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

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

retrieve

public java.lang.Object retrieve(java.lang.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

public void store(java.lang.String key,
                  java.lang.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

public void storeGroup(java.lang.String groupName,
                       java.util.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

public java.util.Set retrieveGroup(java.lang.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

See www.opensymphony.com for more information.