01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.oscache.base.algorithm;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09:
10: /**
11: * A simple unlimited cache that has no upper bound to the number of
12: * cache entries it can contain.
13: *
14: * @version $Revision: 427 $
15: * @author <a href="mailto:fbeauregard@pyxis-tech.com">Francois Beauregard</a>
16: * @author <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
17: */
18: public final class UnlimitedCache extends AbstractConcurrentReadCache {
19:
20: private static final long serialVersionUID = 7615611393249532285L;
21:
22: private final Log log = LogFactory.getLog(this .getClass());
23:
24: /**
25: * Creates an unlimited cache by calling the super class's constructor
26: * with an <code>UNLIMITED</code> maximum number of entries.
27: */
28: public UnlimitedCache() {
29: super ();
30: maxEntries = UNLIMITED;
31: }
32:
33: /**
34: * Overrides the <code>setMaxEntries</code> with an empty implementation.
35: * This property cannot be modified and is ignored for an
36: * <code>UnlimitedCache</code>.
37: */
38: public void setMaxEntries(int maxEntries) {
39: log.warn("Cache max entries can't be set in "
40: + this .getClass().getName() + ", ignoring value "
41: + maxEntries + ".");
42: }
43:
44: /**
45: * Implements <code>itemRetrieved</code> with an empty implementation.
46: * The unlimited cache doesn't care that an item was retrieved.
47: */
48: protected void itemRetrieved(Object key) {
49: }
50:
51: /**
52: * Implements <code>itemPut</code> with an empty implementation.
53: * The unlimited cache doesn't care that an item was put in the cache.
54: */
55: protected void itemPut(Object key) {
56: }
57:
58: /**
59: * This method just returns <code>null</code> since items should
60: * never end up being removed from an unlimited cache!
61: */
62: protected Object removeItem() {
63: return null;
64: }
65:
66: /**
67: * An empty implementation. The unlimited cache doesn't care that an
68: * item was removed.
69: */
70: protected void itemRemoved(Object key) {
71: }
72: }
|