KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > cache > Cache


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.excalibur.cache;
9
10 import org.apache.avalon.framework.component.Component;
11
12 /**
13  * This is a cache that caches objects for reuse.
14  * Key is must not <code>null</code>. Value is possible to <code>null</code>.
15  *
16  * @author <a HREF="mailto:colus@apache.org">Eung-ju Park</a>
17  */

18 public interface Cache
19     extends Component
20 {
21     /**
22      * Add listener.
23      *
24      * @param listener listener instance to add
25      */

26     void addListener( CacheListener listener );
27
28     /**
29      * Remove listener.
30      *
31      * @param listener listener instance to remove
32      */

33     void removeListener( CacheListener listener );
34
35     /**
36      * Return capacity of cache.
37      *
38      * @return capacity of cache
39      */

40     int capacity();
41
42     /**
43      * Return size of cache.
44      *
45      * @return the number of key-value mappings in this cache.
46      */

47     int size();
48
49     /**
50      * Puts a new item in the cache. If the cache is full, remove the selected item.
51      *
52      * @param key key for the item
53      * @param value item
54      * @return old value. null if old value not exists.
55      */

56     Object JavaDoc put( Object JavaDoc key, Object JavaDoc value );
57
58     /**
59      * Get an item from the cache.
60      *
61      * @param key key to lookup the item
62      * @return the matching object in the cache. null if item not exists.
63      */

64     Object JavaDoc get( Object JavaDoc key );
65
66     /**
67      * Removes an item from the cache.
68      *
69      * @param key key to remove
70      * @return the value removed. null if old value not exists.
71      */

72     Object JavaDoc remove( Object JavaDoc key );
73
74     /**
75      * @param key
76      * @return true if matching item in the cache
77      */

78     boolean containsKey( Object JavaDoc key );
79
80     /**
81      * Clear cache.
82      */

83     void clear();
84 }
85
Popular Tags