2 * Copyright 2005 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.wamblee.cache;
19 import java.io.Serializable;
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.
28 public interface Cache<KeyType extends Serializable, ValueType extends Serializable> {
31 * Adds a key-value pair to the cache.
33 * @param aValue Value.
35 void put(KeyType aKey, ValueType aValue);
38 * Retrieves a value from the cache.
39 * @param aKey Key to retrieve.
42 ValueType get(KeyType aKey);
45 * Removes an entry from the cache.
46 * @param aKey Key to remove the entry for.
48 void remove(KeyType aKey);
51 * Removes all entries from the cache.