1 /**
2 * Copyright 2003-2006 Greg Luck
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 net.sf.ehcache.store;
18
19 import net.sf.ehcache.CacheException;
20 import net.sf.ehcache.Element;
21 import net.sf.ehcache.Status;
22
23 /**
24 * This is the interface for all stores. A store is a physical counterpart to a cache, which
25 * is a logical concept.
26 *
27 * @author Greg Luck
28 * @version $Id: Store.java 51 2006-04-24 09:21:10Z gregluck $
29 */
30 public interface Store {
31
32 /**
33 * Puts an item into the cache.
34 */
35 void put(Element element) throws CacheException;
36
37 /**
38 * Gets an item from the cache.
39 */
40 Element get(Object key);
41
42 /**
43 * Removes an item from the cache.
44 *
45 * @since signature changed in 1.2 from boolean to Element to support notifications
46 */
47 Element remove(Object key);
48
49 /**
50 * Remove all of the elements from the store.
51 * <p/>
52 * If there are registered <code>CacheEventListener</code>s they are notified of the expiry or removal
53 * of the <code>Element</code> as each is removed.
54 */
55 void removeAll() throws CacheException;
56
57 /**
58 * Prepares for shutdown.
59 */
60 void dispose();
61
62 /**
63 * Returns the current store size.
64 */
65 int getSize();
66
67 /**
68 * Returns the cache status.
69 */
70 Status getStatus();
71
72
73 /**
74 * A check to see if a key is in the Store.
75 *
76 * @param key The Element key
77 * @return true if found. No check is made to see if the Element is expired.
78 * 1.2
79 */
80 boolean containsKey(Object key);
81
82 }