1 package org.apache.commons.jcs.auxiliary.disk.indexed;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCacheAttributes;
23
24 /**
25 * Configuration class for the Indexed Disk Cache
26 */
27 public class IndexedDiskCacheAttributes
28 extends AbstractDiskCacheAttributes
29 {
30 /** Don't change. */
31 private static final long serialVersionUID = -2190863599358782950L;
32
33 /** default value */
34 private static final int DEFAULT_maxKeySize = 5000;
35
36 /** -1 means no limit. */
37 private int maxKeySize = DEFAULT_maxKeySize;
38
39 /** default to -1, i.e., don't optimize until shutdown */
40 private int optimizeAtRemoveCount = -1;
41
42 /** Should we optimize on shutdown. */
43 public static final boolean DEFAULT_OPTIMIZE_ON_SHUTDOWN = true;
44
45 /** Should we optimize on shutdown. */
46 private boolean optimizeOnShutdown = DEFAULT_OPTIMIZE_ON_SHUTDOWN;
47
48 /** Should we clear the disk on startup. */
49 public static final boolean DEFAULT_CLEAR_DISK_ON_STARTUP = false;
50
51 /** Should we clear the disk on startup. If true the contents of disk are cleared. */
52 private boolean clearDiskOnStartup = DEFAULT_CLEAR_DISK_ON_STARTUP;
53
54 /**
55 * Constructor for the DiskCacheAttributes object
56 */
57 public IndexedDiskCacheAttributes()
58 {
59 super();
60 }
61
62 /**
63 * Gets the maxKeySize attribute of the DiskCacheAttributes object
64 * <p>
65 * @return The maxKeySize value
66 */
67 public int getMaxKeySize()
68 {
69 return this.maxKeySize;
70 }
71
72 /**
73 * Sets the maxKeySize attribute of the DiskCacheAttributes object
74 * <p>
75 * @param maxKeySize The new maxKeySize value
76 */
77 public void setMaxKeySize( int maxKeySize )
78 {
79 this.maxKeySize = maxKeySize;
80 }
81
82 /**
83 * Gets the optimizeAtRemoveCount attribute of the DiskCacheAttributes object
84 * <p>
85 * @return The optimizeAtRemoveCount value
86 */
87 public int getOptimizeAtRemoveCount()
88 {
89 return this.optimizeAtRemoveCount;
90 }
91
92 /**
93 * Sets the optimizeAtRemoveCount attribute of the DiskCacheAttributes object This number
94 * determines how often the disk cache should run real time optimizations.
95 * <p>
96 * @param cnt The new optimizeAtRemoveCount value
97 */
98 public void setOptimizeAtRemoveCount( int cnt )
99 {
100 this.optimizeAtRemoveCount = cnt;
101 }
102
103 /**
104 * @param optimizeOnShutdown The optimizeOnShutdown to set.
105 */
106 public void setOptimizeOnShutdown( boolean optimizeOnShutdown )
107 {
108 this.optimizeOnShutdown = optimizeOnShutdown;
109 }
110
111 /**
112 * @return Returns the optimizeOnShutdown.
113 */
114 public boolean isOptimizeOnShutdown()
115 {
116 return optimizeOnShutdown;
117 }
118
119 /**
120 * @param clearDiskOnStartup the clearDiskOnStartup to set
121 */
122 public void setClearDiskOnStartup( boolean clearDiskOnStartup )
123 {
124 this.clearDiskOnStartup = clearDiskOnStartup;
125 }
126
127 /**
128 * @return the clearDiskOnStartup
129 */
130 public boolean isClearDiskOnStartup()
131 {
132 return clearDiskOnStartup;
133 }
134
135 /**
136 * Write out the values for debugging purposes.
137 * <p>
138 * @return String
139 */
140 @Override
141 public String toString()
142 {
143 StringBuilder str = new StringBuilder();
144 str.append( "IndexedDiskCacheAttributes " );
145 str.append( "\n diskPath = " + super.getDiskPath() );
146 str.append( "\n maxPurgatorySize = " + super.getMaxPurgatorySize() );
147 str.append( "\n maxKeySize = " + maxKeySize );
148 str.append( "\n optimizeAtRemoveCount = " + optimizeAtRemoveCount );
149 str.append( "\n shutdownSpoolTimeLimit = " + super.getShutdownSpoolTimeLimit() );
150 str.append( "\n optimizeOnShutdown = " + optimizeOnShutdown );
151 str.append( "\n clearDiskOnStartup = " + clearDiskOnStartup );
152 return str.toString();
153 }
154 }