1 package org.apache.jcs.auxiliary.disk.block;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.jcs.auxiliary.disk.AbstractDiskCacheAttributes;
23
24 /***
25 * This holds attributes for Block Disk Cache configuration.
26 * <p>
27 * @author Aaron Smuts
28 */
29 public class BlockDiskCacheAttributes
30 extends AbstractDiskCacheAttributes
31 {
32 /*** Don't change */
33 private static final long serialVersionUID = 6568840097657265989L;
34
35 /*** The size per block in bytes. */
36 private int blockSizeBytes;
37
38 /*** Maximum number of keys to be kept in memory */
39 private static final int DEFAULT_MAX_KEY_SIZE = 5000;
40
41 /*** -1 means no limit. */
42 private int maxKeySize = DEFAULT_MAX_KEY_SIZE;
43
44 /*** How often should we persist the keys. */
45 private static final long DEFAULT_KEY_PERSISTENCE_INTERVAL_SECONDS = 5 * 60;
46
47 /*** The keys will be persisted at this interval. -1 mean never. */
48 private long keyPersistenceIntervalSeconds = DEFAULT_KEY_PERSISTENCE_INTERVAL_SECONDS;
49
50 /***
51 * The size of the blocks. All blocks are the same size.
52 * <p>
53 * @param blockSizeBytes The blockSizeBytes to set.
54 */
55 public void setBlockSizeBytes( int blockSizeBytes )
56 {
57 this.blockSizeBytes = blockSizeBytes;
58 }
59
60 /***
61 * @return Returns the blockSizeBytes.
62 */
63 public int getBlockSizeBytes()
64 {
65 return blockSizeBytes;
66 }
67
68 /***
69 * @param maxKeySize The maxKeySize to set.
70 */
71 public void setMaxKeySize( int maxKeySize )
72 {
73 this.maxKeySize = maxKeySize;
74 }
75
76 /***
77 * @return Returns the maxKeySize.
78 */
79 public int getMaxKeySize()
80 {
81 return maxKeySize;
82 }
83
84 /***
85 * @param keyPersistenceIntervalSeconds The keyPersistenceIntervalSeconds to set.
86 */
87 public void setKeyPersistenceIntervalSeconds( long keyPersistenceIntervalSeconds )
88 {
89 this.keyPersistenceIntervalSeconds = keyPersistenceIntervalSeconds;
90 }
91
92 /***
93 * @return Returns the keyPersistenceIntervalSeconds.
94 */
95 public long getKeyPersistenceIntervalSeconds()
96 {
97 return keyPersistenceIntervalSeconds;
98 }
99
100 /***
101 * Write out the values for debugging purposes.
102 * <p>
103 * @return String
104 */
105 public String toString()
106 {
107 StringBuffer str = new StringBuffer();
108 str.append( "\nBlockDiskAttributes " );
109 str.append( "\n DiskPath [" + this.getDiskPath() + "]" );
110 str.append( "\n MaxKeySize [" + this.getMaxKeySize() + "]" );
111 str.append( "\n MaxPurgatorySize [" + this.getMaxPurgatorySize() + "]" );
112 str.append( "\n BlockSizeBytes [" + this.getBlockSizeBytes() + "]" );
113 str.append( "\n KeyPersistenceIntervalSeconds [" + this.getKeyPersistenceIntervalSeconds() + "]" );
114 return str.toString();
115 }
116 }