View Javadoc

1   package org.apache.turbine.services.cache;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
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  }