001 package org.apache.fulcrum.cache; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import java.io.IOException; 023 import java.util.List; 024 025 import org.apache.avalon.framework.component.Component; 026 027 /** 028 * GlobalCacheService interface. 029 * 030 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a> 031 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a> 032 * @version $Id: GlobalCacheService.java 927153 2010-03-24 18:55:08Z tv $ 033 */ 034 public interface GlobalCacheService extends Component 035 { 036 /** Avalon role - used to id the component within the manager */ 037 String ROLE = GlobalCacheService.class.getName(); 038 039 /** 040 * Gets a cached object given its id (a String). 041 * 042 * @param id 043 * The String id for the object. 044 * @return A CachedObject. 045 * @exception ObjectExpiredException, 046 * if the object has expired in the cache. 047 */ 048 CachedObject getObject(String id) throws ObjectExpiredException; 049 050 /** 051 * Adds an object to the cache. 052 * 053 * @param id 054 * The String id for the object. 055 * @param o 056 * The object to add to the cache. 057 */ 058 void addObject(String id, CachedObject o); 059 060 /** 061 * Removes an object from the cache. 062 * 063 * @param id 064 * The String id for the object. 065 */ 066 void removeObject(String id); 067 068 /** 069 * Returns a copy of keys to objects in the cache as a list. 070 * 071 * Note that keys to expired objects are not returned. 072 * 073 * @return A List of <code>String</code>'s representing the keys to 074 * objects in the cache. 075 */ 076 public List getKeys(); 077 078 /** 079 * Returns a copy of the non-expired CachedObjects in the cache as a list. 080 * 081 * @return A List of <code>CachedObject</code> objects held in the cache 082 */ 083 public List getCachedObjects(); 084 085 /** 086 * Returns the current size of the cache. 087 * 088 * @return int representing current cache size in number of bytes 089 */ 090 int getCacheSize() throws IOException; 091 092 /** 093 * Returns the number of objects in the cache. 094 * 095 * @return int The current number of objects in the cache. 096 */ 097 int getNumberOfObjects(); 098 099 /** 100 * Flush the cache of all objects. 101 */ 102 void flushCache(); 103 }