001package org.apache.commons.jcs3.auxiliary.disk.jdbc.mysql; 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.jcs3.auxiliary.disk.jdbc.JDBCDiskCacheAttributes; 023 024/** 025 * This has additional attributes that are particular to the MySQL disk cache. 026 */ 027public class MySQLDiskCacheAttributes 028 extends JDBCDiskCacheAttributes 029{ 030 /** Don't change. */ 031 private static final long serialVersionUID = -6535808344813320061L; 032 033 /** 034 * For now this is a simple comma delimited list of HH:MM:SS times to optimize 035 * the table. If none is supplied, then no optimizations will be performed. 036 * <p> 037 * In the future we can add a chron like scheduling system. This is to meet 038 * a pressing current need. 039 * <p> 040 * 03:01,15:00 will cause the optimizer to run at 3 am and at 3 pm. 041 */ 042 private String optimizationSchedule; 043 044 /** 045 * If true, we will balk, that is return null during optimization rather than block. 046 */ 047 public static final boolean DEFAULT_BALK_DURING_OPTIMIZATION = true; 048 049 /** 050 * If true, we will balk, that is return null during optimization rather than block. 051 * <p> 052 * <a href="http://en.wikipedia.org/wiki/Balking_pattern">Balking</a> 053 */ 054 private boolean balkDuringOptimization = DEFAULT_BALK_DURING_OPTIMIZATION; 055 056 /** 057 * @param optimizationSchedule The optimizationSchedule to set. 058 */ 059 public void setOptimizationSchedule( final String optimizationSchedule ) 060 { 061 this.optimizationSchedule = optimizationSchedule; 062 } 063 064 /** 065 * @return Returns the optimizationSchedule. 066 */ 067 public String getOptimizationSchedule() 068 { 069 return optimizationSchedule; 070 } 071 072 /** 073 * @param balkDuringOptimization The balkDuringOptimization to set. 074 */ 075 public void setBalkDuringOptimization( final boolean balkDuringOptimization ) 076 { 077 this.balkDuringOptimization = balkDuringOptimization; 078 } 079 080 /** 081 * Should we return null while optimizing the table. 082 * <p> 083 * @return Returns the balkDuringOptimization. 084 */ 085 public boolean isBalkDuringOptimization() 086 { 087 return balkDuringOptimization; 088 } 089 090 /** 091 * For debugging. 092 * <p> 093 * @return debug string 094 */ 095 @Override 096 public String toString() 097 { 098 final StringBuilder buf = new StringBuilder(); 099 buf.append( "\nMySQLDiskCacheAttributes" ); 100 buf.append( "\n OptimizationSchedule [" + getOptimizationSchedule() + "]" ); 101 buf.append( "\n BalkDuringOptimization [" + isBalkDuringOptimization() + "]" ); 102 buf.append( super.toString() ); 103 return buf.toString(); 104 } 105}