KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > whirlycott > cache > Cacheable


1 /*
2 Copyright 2004 Philip Jacob <phil@whirlycott.com>
3                     Seth Fitzsimmons <seth@note.amherst.edu>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */

17
18 package com.whirlycott.cache;
19
20 /**
21  * This is an <i>optional</i> interface for object keys which may be stored in the cache.
22  * After each retrieve(), store() or remove() operation for a particular Cache, the
23  * corresponding method of the object implementing this interface is called.
24  *
25  * The onRemove(), onStore() and onRetrieve() methods are called both by cache policies
26  * and regular client calls on the Cache interface (i.e. operations within policies
27  * also call these methods).
28  *
29  * Implementing this interface will not result in any performance increase.
30  * On the contrary, additional work per Cache operation will only serve to slow
31  * things down.
32  *
33  * @author Philip Jacob <a HREF="phil@whirlycott.com">phil@whirlycott.com</a>
34  */

35 public interface Cacheable {
36     
37
38     /**
39      * Hook for actions to be performed during a retrieve() operation.
40      * @param _value The value being retrieved. Can possibly be a null value.
41      */

42     public void onRetrieve(Object JavaDoc _value);
43
44
45     /**
46      * Hook for actions to be performed during a store() operation.
47      * @param _value The value being stored. Can possibly be a null value.
48      */

49     public void onStore(Object JavaDoc _value);
50
51
52     /**
53      * Hook for actions to be performed during a remove() operation.
54      * @param _value The value being removed. Can possibly be a null value.
55      */

56     public void onRemove(Object JavaDoc _value);
57 }
58
Popular Tags