(no commit message)
[utils] / support / src / org / wamblee / cache / Cache.java
1 /*
2  * Copyright 2005 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */ 
16
17 package org.wamblee.cache;
18
19 import java.io.Serializable;
20
21 /**
22  * The <code>Cache</code> interface represents... a cache. 
23  * In some circumstances it is more optimal to implement caching directly in 
24  * the code instead of relying on Hibernate caching methods. This interface abstracts
25  * from the used cache implementation. 
26  * Cache implementations must be thread-safe.  
27  */
28 public interface Cache<KeyType extends Serializable, ValueType extends Serializable> {
29
30     /**
31      * Adds a key-value pair to the cache. 
32      * @param aKey Key. 
33      * @param aValue Value. 
34      */
35     void put(KeyType aKey, ValueType aValue); 
36     
37     /**
38      * Retrieves a value from the cache. 
39      * @param aKey Key to retrieve. 
40      * @return Key. 
41      */
42     ValueType get(KeyType aKey);
43     
44     /**
45      * Removes an entry from the cache. 
46      * @param aKey Key to remove the entry for. 
47      */
48     void remove(KeyType aKey); 
49     
50     /**
51      * Removes all entries from the cache. 
52      *
53      */
54     void clear(); 
55 }