01: package org.apache.turbine.services.cache;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import java.io.IOException;
23:
24: import org.apache.turbine.services.Service;
25:
26: /**
27: * GlobalCacheService interface.
28: *
29: * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
30: * @version $Id: GlobalCacheService.java 534527 2007-05-02 16:10:59Z tv $
31: */
32: public interface GlobalCacheService extends Service {
33: String SERVICE_NAME = "GlobalCacheService";
34:
35: /**
36: * Gets a cached object given its id (a String).
37: *
38: * @param id The String id for the object.
39: * @return A CachedObject.
40: * @exception ObjectExpiredException, if the object has expired in
41: * the cache.
42: */
43: CachedObject getObject(String id) 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() throws IOException;
65:
66: /**
67: * Returns the number of objects in the cache.
68: * @return int The current number of objects in the cache.
69: */
70: int getNumberOfObjects();
71:
72: /**
73: * Flush the cache of all objects.
74: */
75: void flushCache();
76: }
|