001package org.apache.commons.jcs.auxiliary.disk.indexed; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.commons.jcs.auxiliary.disk.AbstractDiskCacheAttributes; 023 024/** 025 * Configuration class for the Indexed Disk Cache 026 */ 027public class IndexedDiskCacheAttributes 028 extends AbstractDiskCacheAttributes 029{ 030 /** Don't change. */ 031 private static final long serialVersionUID = -2190863599358782950L; 032 033 /** default value */ 034 private static final int DEFAULT_maxKeySize = 5000; 035 036 /** -1 means no limit. */ 037 private int maxKeySize = DEFAULT_maxKeySize; 038 039 /** default to -1, i.e., don't optimize until shutdown */ 040 private int optimizeAtRemoveCount = -1; 041 042 /** Should we optimize on shutdown. */ 043 public static final boolean DEFAULT_OPTIMIZE_ON_SHUTDOWN = true; 044 045 /** Should we optimize on shutdown. */ 046 private boolean optimizeOnShutdown = DEFAULT_OPTIMIZE_ON_SHUTDOWN; 047 048 /** Should we clear the disk on startup. */ 049 public static final boolean DEFAULT_CLEAR_DISK_ON_STARTUP = false; 050 051 /** Should we clear the disk on startup. If true the contents of disk are cleared. */ 052 private boolean clearDiskOnStartup = DEFAULT_CLEAR_DISK_ON_STARTUP; 053 054 /** 055 * Constructor for the DiskCacheAttributes object 056 */ 057 public IndexedDiskCacheAttributes() 058 { 059 super(); 060 } 061 062 /** 063 * Gets the maxKeySize attribute of the DiskCacheAttributes object 064 * <p> 065 * @return The maxKeySize value 066 */ 067 public int getMaxKeySize() 068 { 069 return this.maxKeySize; 070 } 071 072 /** 073 * Sets the maxKeySize attribute of the DiskCacheAttributes object 074 * <p> 075 * @param maxKeySize The new maxKeySize value 076 */ 077 public void setMaxKeySize( int maxKeySize ) 078 { 079 this.maxKeySize = maxKeySize; 080 } 081 082 /** 083 * Gets the optimizeAtRemoveCount attribute of the DiskCacheAttributes object 084 * <p> 085 * @return The optimizeAtRemoveCount value 086 */ 087 public int getOptimizeAtRemoveCount() 088 { 089 return this.optimizeAtRemoveCount; 090 } 091 092 /** 093 * Sets the optimizeAtRemoveCount attribute of the DiskCacheAttributes object This number 094 * determines how often the disk cache should run real time optimizations. 095 * <p> 096 * @param cnt The new optimizeAtRemoveCount value 097 */ 098 public void setOptimizeAtRemoveCount( int cnt ) 099 { 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}