1 package org.apache.turbine.services.cache;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.IOException;
20
21 import org.apache.turbine.services.Service;
22
23 /***
24 * GlobalCacheService interface.
25 *
26 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
27 * @version $Id: GlobalCacheService.java 264148 2005-08-29 14:21:04Z henning $
28 */
29 public interface GlobalCacheService
30 extends Service
31 {
32 String SERVICE_NAME = "GlobalCacheService";
33
34 /***
35 * Gets a cached object given its id (a String).
36 *
37 * @param id The String id for the object.
38 * @return A CachedObject.
39 * @exception ObjectExpiredException, if the object has expired in
40 * the cache.
41 */
42 CachedObject getObject(String id)
43 throws ObjectExpiredException;
44
45 /***
46 * Adds an object to the cache.
47 *
48 * @param id The String id for the object.
49 * @param o The object to add to the cache.
50 */
51 void addObject(String id, CachedObject o);
52
53 /***
54 * Removes an object from the cache.
55 *
56 * @param id The String id for the object.
57 */
58 void removeObject(String id);
59
60 /***
61 * Returns the current size of the cache.
62 * @return int representing current cache size in number of bytes
63 */
64 int getCacheSize()
65 throws IOException;
66
67 /***
68 * Returns the number of objects in the cache.
69 * @return int The current number of objects in the cache.
70 */
71 int getNumberOfObjects();
72
73 /***
74 * Flush the cache of all objects.
75 */
76 void flushCache();
77 }