KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > cache > Cache


1 //$Id: Cache.java,v 1.7 2005/04/21 07:57:19 oneovthafew Exp $
2
package org.hibernate.cache;
3
4 import java.util.Map JavaDoc;
5
6 /**
7  * Implementors define a caching algorithm. All implementors
8  * <b>must</b> be threadsafe.
9  */

10 public interface Cache {
11     /**
12      * Get an item from the cache
13      * @param key
14      * @return the cached object or <tt>null</tt>
15      * @throws CacheException
16      */

17     public Object JavaDoc read(Object JavaDoc key) throws CacheException;
18     /**
19      * Get an item from the cache, nontransactionally
20      * @param key
21      * @return the cached object or <tt>null</tt>
22      * @throws CacheException
23      */

24     public Object JavaDoc get(Object JavaDoc key) throws CacheException;
25     /**
26      * Add an item to the cache, nontransactionally, with
27      * failfast semantics
28      * @param key
29      * @param value
30      * @throws CacheException
31      */

32     public void put(Object JavaDoc key, Object JavaDoc value) throws CacheException;
33     /**
34      * Add an item to the cache
35      * @param key
36      * @param value
37      * @throws CacheException
38      */

39     public void update(Object JavaDoc key, Object JavaDoc value) throws CacheException;
40     /**
41      * Remove an item from the cache
42      */

43     public void remove(Object JavaDoc key) throws CacheException;
44     /**
45      * Clear the cache
46      */

47     public void clear() throws CacheException;
48     /**
49      * Clean up
50      */

51     public void destroy() throws CacheException;
52     /**
53      * If this is a clustered cache, lock the item
54      */

55     public void lock(Object JavaDoc key) throws CacheException;
56     /**
57      * If this is a clustered cache, unlock the item
58      */

59     public void unlock(Object JavaDoc key) throws CacheException;
60     /**
61      * Generate a timestamp
62      */

63     public long nextTimestamp();
64     /**
65      * Get a reasonable "lock timeout"
66      */

67     public int getTimeout();
68     
69     /**
70      * Get the name of the cache region
71      */

72     public String JavaDoc getRegionName();
73
74     /**
75      * The number of bytes is this cache region currently consuming in memory.
76      *
77      * @return The number of bytes consumed by this region; -1 if unknown or
78      * unsupported.
79      */

80     public long getSizeInMemory();
81
82     /**
83      * The count of entries currently contained in the regions in-memory store.
84      *
85      * @return The count of entries in memory; -1 if unknown or unsupported.
86      */

87     public long getElementCountInMemory();
88
89     /**
90      * The count of entries currently contained in the regions disk store.
91      *
92      * @return The count of entries on disk; -1 if unknown or unsupported.
93      */

94     public long getElementCountOnDisk();
95     
96     /**
97      * optional operation
98      */

99     public Map JavaDoc toMap();
100 }
101
102
103
104
105
106
107
Popular Tags