View Javadoc
1   package org.apache.commons.jcs3.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.jcs3.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      }
60  
61      /**
62       * Gets the maxKeySize attribute of the DiskCacheAttributes object
63       * <p>
64       * @return The maxKeySize value
65       */
66      public int getMaxKeySize()
67      {
68          return this.maxKeySize;
69      }
70  
71      /**
72       * Sets the maxKeySize attribute of the DiskCacheAttributes object
73       * <p>
74       * @param maxKeySize The new maxKeySize value
75       */
76      public void setMaxKeySize( final int maxKeySize )
77      {
78          this.maxKeySize = maxKeySize;
79      }
80  
81      /**
82       * Gets the optimizeAtRemoveCount attribute of the DiskCacheAttributes object
83       * <p>
84       * @return The optimizeAtRemoveCount value
85       */
86      public int getOptimizeAtRemoveCount()
87      {
88          return this.optimizeAtRemoveCount;
89      }
90  
91      /**
92       * Sets the optimizeAtRemoveCount attribute of the DiskCacheAttributes object This number
93       * determines how often the disk cache should run real time optimizations.
94       * <p>
95       * @param cnt The new optimizeAtRemoveCount value
96       */
97      public void setOptimizeAtRemoveCount( final int cnt )
98      {
99          this.optimizeAtRemoveCount = cnt;
100     }
101 
102     /**
103      * @param optimizeOnShutdown The optimizeOnShutdown to set.
104      */
105     public void setOptimizeOnShutdown( final boolean optimizeOnShutdown )
106     {
107         this.optimizeOnShutdown = optimizeOnShutdown;
108     }
109 
110     /**
111      * @return Returns the optimizeOnShutdown.
112      */
113     public boolean isOptimizeOnShutdown()
114     {
115         return optimizeOnShutdown;
116     }
117 
118     /**
119      * @param clearDiskOnStartup the clearDiskOnStartup to set
120      */
121     public void setClearDiskOnStartup( final boolean clearDiskOnStartup )
122     {
123         this.clearDiskOnStartup = clearDiskOnStartup;
124     }
125 
126     /**
127      * @return the clearDiskOnStartup
128      */
129     public boolean isClearDiskOnStartup()
130     {
131         return clearDiskOnStartup;
132     }
133 
134     /**
135      * Write out the values for debugging purposes.
136      * <p>
137      * @return String
138      */
139     @Override
140     public String toString()
141     {
142         final StringBuilder str = new StringBuilder();
143         str.append( "IndexedDiskCacheAttributes " );
144         str.append( "\n diskPath = " + super.getDiskPath() );
145         str.append( "\n maxPurgatorySize   = " + super.getMaxPurgatorySize() );
146         str.append( "\n maxKeySize  = " + maxKeySize );
147         str.append( "\n optimizeAtRemoveCount  = " + optimizeAtRemoveCount );
148         str.append( "\n shutdownSpoolTimeLimit  = " + super.getShutdownSpoolTimeLimit() );
149         str.append( "\n optimizeOnShutdown  = " + optimizeOnShutdown );
150         str.append( "\n clearDiskOnStartup  = " + clearDiskOnStartup );
151         return str.toString();
152     }
153 }