1 /*
2 * Copyright 2001-2004 The Apache Software Foundation
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 package org.apache.commons.cache;
17
18 import java.io.Serializable;
19
20 /**
21 * A {@link Cache} that doesn't.
22 * @version $Id: NoOpCache.java 155435 2005-02-26 13:17:27Z dirkv $
23 * @author Rodney Waldhoff
24 */
25 public class NoOpCache extends BaseCache implements Cache {
26 /** Returns <tt>false</tt>. */
27 public boolean store(Serializable key, Serializable val, Long expiry, Long cost, Serializable group) {
28 broadcastStoreRequested(key,val,expiry,cost,group);
29 broadcastNotStored(key,val,expiry,cost,group);
30 return false;
31 }
32
33 /** Returns <tt>null</tt>. */
34 public Serializable retrieve(Serializable key) {
35 broadcastRetrieveRequested(key);
36 broadcastNotRetrieved(key);
37 return null;
38 }
39
40 /** Returns an empty array. */
41 public Serializable[] getKeysForGroup(Serializable group) {
42 return new Serializable[0];
43 }
44
45 /** Returns <tt>false</tt> */
46 public boolean contains(Serializable key) {
47 return false;
48 }
49
50 /** No-op. */
51 public void clear(Serializable key) {
52 }
53
54 /** No-op. */
55 public void clearGroup(Serializable group) {
56 }
57
58 /** No-op. */
59 public void clear() {
60 }
61
62 /** Throws {@link UnsupportedOperationException} */
63 public long getStat(CacheStat stat) throws UnsupportedOperationException {
64 throw new UnsupportedOperationException();
65 }
66 }