1 package org.apache.commons.jcs.auxiliary.disk.jdbc.mysql; 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.jdbc.JDBCDiskCacheAttributes; 23 24 /** 25 * This has additional attributes that are particular to the MySQL disk cache. 26 * <p> 27 * @author Aaron Smuts 28 */ 29 public class MySQLDiskCacheAttributes 30 extends JDBCDiskCacheAttributes 31 { 32 /** Don't change. */ 33 private static final long serialVersionUID = -6535808344813320061L; 34 35 /** 36 * For now this is a simple comma delimited list of HH:MM:SS times to optimize 37 * the table. If none is supplied, then no optimizations will be performed. 38 * <p> 39 * In the future we can add a chron like scheduling system. This is to meet 40 * a pressing current need. 41 * <p> 42 * 03:01,15:00 will cause the optimizer to run at 3 am and at 3 pm. 43 */ 44 private String optimizationSchedule = null; 45 46 /** 47 * If true, we will balk, that is return null during optimization rather than block. 48 */ 49 public static final boolean DEFAULT_BALK_DURING_OPTIMIZATION = true; 50 51 /** 52 * If true, we will balk, that is return null during optimization rather than block. 53 * <p> 54 * <a href="http://en.wikipedia.org/wiki/Balking_pattern">Balking</a> 55 */ 56 private boolean balkDuringOptimization = DEFAULT_BALK_DURING_OPTIMIZATION; 57 58 /** 59 * @param optimizationSchedule The optimizationSchedule to set. 60 */ 61 public void setOptimizationSchedule( String optimizationSchedule ) 62 { 63 this.optimizationSchedule = optimizationSchedule; 64 } 65 66 /** 67 * @return Returns the optimizationSchedule. 68 */ 69 public String getOptimizationSchedule() 70 { 71 return optimizationSchedule; 72 } 73 74 /** 75 * @param balkDuringOptimization The balkDuringOptimization to set. 76 */ 77 public void setBalkDuringOptimization( boolean balkDuringOptimization ) 78 { 79 this.balkDuringOptimization = balkDuringOptimization; 80 } 81 82 /** 83 * Should we return null while optimizing the table. 84 * <p> 85 * @return Returns the balkDuringOptimization. 86 */ 87 public boolean isBalkDuringOptimization() 88 { 89 return balkDuringOptimization; 90 } 91 92 /** 93 * For debugging. 94 * <p> 95 * @return debug string 96 */ 97 @Override 98 public String toString() 99 { 100 StringBuilder buf = new StringBuilder(); 101 buf.append( "\nMySQLDiskCacheAttributes" ); 102 buf.append( "\n OptimizationSchedule [" + getOptimizationSchedule() + "]" ); 103 buf.append( "\n BalkDuringOptimization [" + isBalkDuringOptimization() + "]" ); 104 buf.append( super.toString() ); 105 return buf.toString(); 106 } 107 }