1 package org.apache.jcs.auxiliary.disk;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.jcs.utils.struct.LRUMap;
25
26 /***
27 * Extension of LRUMap for logging of removals. Can switch this back to a HashMap easily. This
28 * provides some abstraction. It also makes it easy to log overflow.
29 */
30 public class LRUMapJCS
31 extends LRUMap
32 {
33 /*** Don't change */
34 private static final long serialVersionUID = 776964015449842672L;
35
36 /*** The logger */
37 private static final Log log = LogFactory.getLog( LRUMapJCS.class );
38
39 /***
40 * This creates an unbounded version.
41 */
42 public LRUMapJCS()
43 {
44 super();
45 }
46
47 /***
48 * This creates a list bounded by the max key size argument. The Boundary is enforces by an LRU
49 * eviction policy.
50 * <p>
51 * This is used in the Disk cache to store keys and purgatory elements if a boundary is
52 * requested.
53 * <p>
54 * The LRU memory cache uses its own LRU implementation.
55 * <p>
56 * @param maxKeySize
57 */
58 public LRUMapJCS( int maxKeySize )
59 {
60 super( maxKeySize );
61 }
62
63 /***
64 * This is called when an item is removed from the LRU. We just log some information.
65 * <p>
66 * @param key
67 * @param value
68 */
69 protected void processRemovedLRU( Object key, Object value )
70 {
71 if ( log.isDebugEnabled() )
72 {
73 log.debug( "Removing key [" + key + "] from key store, value [" + value + "]" );
74 log.debug( "Key store size [" + this.size() + "]" );
75 }
76 }
77 }