001package org.apache.commons.jcs.engine.behavior; 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 java.io.Serializable; 023 024/** 025 * This defines the minimal behavior for the Cache Configuration settings. 026 */ 027public interface ICompositeCacheAttributes 028 extends Serializable, Cloneable 029{ 030 enum DiskUsagePattern 031 { 032 /** Items will only go to disk when the memory limit is reached. This is the default. */ 033 SWAP, 034 035 /** 036 * Items will go to disk on a normal put. If The disk usage pattern is UPDATE, the swap will be 037 * disabled. 038 */ 039 UPDATE 040 } 041 042 /** 043 * SetMaxObjects is used to set the attribute to determine the maximum 044 * number of objects allowed in the memory cache. If the max number of 045 * objects or the cache size is set, the default for the one not set is 046 * ignored. If both are set, both are used to determine the capacity of the 047 * cache, i.e., object will be removed from the cache if either limit is 048 * reached. TODO: move to MemoryCache config file. 049 * <p> 050 * @param size 051 * The new maxObjects value 052 */ 053 void setMaxObjects( int size ); 054 055 /** 056 * Gets the maxObjects attribute of the ICompositeCacheAttributes object 057 * <p> 058 * @return The maxObjects value 059 */ 060 int getMaxObjects(); 061 062 /** 063 * Sets the useDisk attribute of the ICompositeCacheAttributes object 064 * <p> 065 * @param useDisk 066 * The new useDisk value 067 */ 068 void setUseDisk( boolean useDisk ); 069 070 /** 071 * Gets the useDisk attribute of the ICompositeCacheAttributes object 072 * <p> 073 * @return The useDisk value 074 */ 075 boolean isUseDisk(); 076 077 /** 078 * set whether the cache should use a lateral cache 079 * <p> 080 * @param d 081 * The new useLateral value 082 */ 083 void setUseLateral( boolean d ); 084 085 /** 086 * Gets the useLateral attribute of the ICompositeCacheAttributes object 087 * <p> 088 * @return The useLateral value 089 */ 090 boolean isUseLateral(); 091 092 /** 093 * Sets whether the cache is remote enabled 094 * <p> 095 * @param isRemote 096 * The new useRemote value 097 */ 098 void setUseRemote( boolean isRemote ); 099 100 /** 101 * returns whether the cache is remote enabled 102 * <p> 103 * @return The useRemote value 104 */ 105 boolean isUseRemote(); 106 107 /** 108 * Sets the name of the cache, referenced by the appropriate manager. 109 * <p> 110 * @param s 111 * The new cacheName value 112 */ 113 void setCacheName( String s ); 114 115 /** 116 * Gets the cacheName attribute of the ICompositeCacheAttributes object 117 * <p> 118 * @return The cacheName value 119 */ 120 String getCacheName(); 121 122 /** 123 * Sets the name of the MemoryCache, referenced by the appropriate manager. 124 * TODO: create a separate memory cache attribute class. 125 * <p> 126 * @param s 127 * The new memoryCacheName value 128 */ 129 void setMemoryCacheName( String s ); 130 131 /** 132 * Gets the memoryCacheName attribute of the ICompositeCacheAttributes 133 * object 134 * <p> 135 * @return The memoryCacheName value 136 */ 137 String getMemoryCacheName(); 138 139 /** 140 * Whether the memory cache should perform background memory shrinkage. 141 * <p> 142 * @param useShrinker 143 * The new UseMemoryShrinker value 144 */ 145 void setUseMemoryShrinker( boolean useShrinker ); 146 147 /** 148 * Whether the memory cache should perform background memory shrinkage. 149 * <p> 150 * @return The UseMemoryShrinker value 151 */ 152 boolean isUseMemoryShrinker(); 153 154 /** 155 * If UseMemoryShrinker is true the memory cache should auto-expire elements 156 * to reclaim space. 157 * <p> 158 * @param seconds 159 * The new MaxMemoryIdleTimeSeconds value 160 */ 161 void setMaxMemoryIdleTimeSeconds( long seconds ); 162 163 /** 164 * If UseMemoryShrinker is true the memory cache should auto-expire elements 165 * to reclaim space. 166 * <p> 167 * @return The MaxMemoryIdleTimeSeconds value 168 */ 169 long getMaxMemoryIdleTimeSeconds(); 170 171 /** 172 * If UseMemoryShrinker is true the memory cache should auto-expire elements 173 * to reclaim space. This sets the shrinker interval. 174 * <p> 175 * @param seconds 176 * The new ShrinkerIntervalSeconds value 177 */ 178 void setShrinkerIntervalSeconds( long seconds ); 179 180 /** 181 * If UseMemoryShrinker is true the memory cache should auto-expire elements 182 * to reclaim space. This gets the shrinker interval. 183 * <p> 184 * @return The ShrinkerIntervalSeconds value 185 */ 186 long getShrinkerIntervalSeconds(); 187 188 /** 189 * If UseMemoryShrinker is true the memory cache should auto-expire elements 190 * to reclaim space. This sets the maximum number of items to spool per run. 191 * <p> 192 * @param maxSpoolPerRun 193 * The new maxSpoolPerRun value 194 */ 195 void setMaxSpoolPerRun( int maxSpoolPerRun ); 196 197 /** 198 * If UseMemoryShrinker is true the memory cache should auto-expire elements 199 * to reclaim space. This gets the maximum number of items to spool per run. 200 * <p> 201 * @return The maxSpoolPerRun value 202 */ 203 int getMaxSpoolPerRun(); 204 205 /** 206 * By default this is SWAP_ONLY. 207 * <p> 208 * @param diskUsagePattern The diskUsagePattern to set. 209 */ 210 void setDiskUsagePattern( DiskUsagePattern diskUsagePattern ); 211 212 /** 213 * Translates the name to the disk usage pattern short value. 214 * <p> 215 * The allowed values are SWAP and UPDATE. 216 * <p> 217 * @param diskUsagePatternName The diskUsagePattern to set. 218 */ 219 void setDiskUsagePatternName( String diskUsagePatternName ); 220 221 /** 222 * @return Returns the diskUsagePattern. 223 */ 224 DiskUsagePattern getDiskUsagePattern(); 225 226 /** 227 * Number to send to disk at at time when memory is full. 228 * <p> 229 * @return int 230 */ 231 int getSpoolChunkSize(); 232 233 /** 234 * Number to send to disk at a time. 235 * <p> 236 * @param spoolChunkSize 237 */ 238 void setSpoolChunkSize( int spoolChunkSize ); 239 240 /** 241 * Clone object 242 */ 243 ICompositeCacheAttributes clone(); 244}