01: /*
02: Copyright 2004 Philip Jacob <phil@whirlycott.com>
03: Seth Fitzsimmons <seth@note.amherst.edu>
04:
05: Licensed under the Apache License, Version 2.0 (the "License");
06: you may not use this file except in compliance with the License.
07: You may obtain a copy of the License at
08:
09: 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: * Hook for actions to be performed during a retrieve() operation.
39: * @param _value The value being retrieved. Can possibly be a null value.
40: */
41: public void onRetrieve(Object _value);
42:
43: /**
44: * Hook for actions to be performed during a store() operation.
45: * @param _value The value being stored. Can possibly be a null value.
46: */
47: public void onStore(Object _value);
48:
49: /**
50: * Hook for actions to be performed during a remove() operation.
51: * @param _value The value being removed. Can possibly be a null value.
52: */
53: public void onRemove(Object _value);
54: }
|