KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > oscache > base > persistence > PersistenceListener


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.oscache.base.persistence;
6
7 import com.opensymphony.oscache.base.Config;
8
9 import java.util.Set JavaDoc;
10
11 /**
12  * Defines the methods that are required to persist cache data.
13  * To provide a custom persistence mechanism you should implement this
14  * interface and supply the fully-qualified classname to the cache via
15  * the <code>cache.persistence.class</code> configuration property.
16  *
17  * @version $Revision: 1.1 $
18  * @author <a HREF="mailto:fbeauregard@pyxis-tech.com">Francois Beauregard</a>
19  */

20 public interface PersistenceListener {
21     /**
22      * Verify if an object is currently stored in the persistent cache.
23      *
24      * @param key The cache key of the object to check.
25      */

26     public boolean isStored(String JavaDoc key) throws CachePersistenceException;
27
28     /**
29      * Verify if a group is currently stored in the persistent cache.
30      *
31      * @param groupName The name of the group to check.
32      */

33     public boolean isGroupStored(String JavaDoc groupName) throws CachePersistenceException;
34
35     /**
36      * Clear the entire persistent cache (including the root)
37      */

38     public void clear() throws CachePersistenceException;
39
40     /**
41      * Allow the persistence code to initialize itself based on the supplied
42      * cache configuration.
43      */

44     public PersistenceListener configure(Config config);
45
46     /**
47      * Removes an object from the persistent cache
48      */

49     public void remove(String JavaDoc key) throws CachePersistenceException;
50
51     /**
52      * Removes a group from the persistent cache.
53      *
54      * @param groupName The name of the cache group to remove.
55      */

56     public void removeGroup(String JavaDoc groupName) throws CachePersistenceException;
57
58     /**
59      * Retrieves an object from the persistent cache.
60      *
61      * @param key The unique cache key that maps to the object
62      * being retrieved.
63      * @return The object, or <code>null</code> if no object was found
64      * matching the supplied key.
65      */

66     public Object JavaDoc retrieve(String JavaDoc key) throws CachePersistenceException;
67
68     /**
69      * Stores an object in the persistent cache.
70      *
71      * @param key The key to uniquely identify this object.
72      * @param obj The object to persist. Most implementations
73      * of this interface will require this object implements
74      * <code>Serializable</code>.
75      */

76     public void store(String JavaDoc key, Object JavaDoc obj) throws CachePersistenceException;
77
78     /**
79      * Stores a group in the persistent cache.
80      *
81      * @param groupName The name of the group to persist.
82      * @param group A set containing the keys of all the <code>CacheEntry</code>
83      * objects that belong to this group.
84      */

85     public void storeGroup(String JavaDoc groupName, Set JavaDoc group) throws CachePersistenceException;
86
87     /**
88      * Retrieves a group from the persistent cache.
89      *
90      * @param groupName The name of the group to retrieve.
91      * @return The returned set should contain the keys
92      * of all the <code>CacheEntry</code> objects that belong
93      * to this group.
94      */

95     Set JavaDoc retrieveGroup(String JavaDoc groupName) throws CachePersistenceException;
96 }
97
Popular Tags