View Javadoc
1   package org.apache.commons.jcs3.engine.behavior;
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 java.io.Serializable;
23  
24  /**
25   * This defines the minimal behavior for the Cache Configuration settings.
26   */
27  public interface ICompositeCacheAttributes
28      extends Serializable, Cloneable
29  {
30      enum DiskUsagePattern
31      {
32          /** Items will only go to disk when the memory limit is reached. This is the default. */
33          SWAP,
34  
35          /**
36           * Items will go to disk on a normal put. If The disk usage pattern is UPDATE, the swap will be
37           * disabled.
38           */
39          UPDATE
40      }
41  
42      /**
43       * SetMaxObjects is used to set the attribute to determine the maximum
44       * number of objects allowed in the memory cache. If the max number of
45       * objects or the cache size is set, the default for the one not set is
46       * ignored. If both are set, both are used to determine the capacity of the
47       * cache, i.e., object will be removed from the cache if either limit is
48       * reached. TODO: move to MemoryCache config file.
49       * <p>
50       * @param size
51       *            The new maxObjects value
52       */
53      void setMaxObjects( int size );
54  
55      /**
56       * Gets the maxObjects attribute of the ICompositeCacheAttributes object
57       * <p>
58       * @return The maxObjects value
59       */
60      int getMaxObjects();
61  
62      /**
63       * Sets the useDisk attribute of the ICompositeCacheAttributes object
64       * <p>
65       * @param useDisk
66       *            The new useDisk value
67       */
68      void setUseDisk( boolean useDisk );
69  
70      /**
71       * Gets the useDisk attribute of the ICompositeCacheAttributes object
72       * <p>
73       * @return The useDisk value
74       */
75      boolean isUseDisk();
76  
77      /**
78       * set whether the cache should use a lateral cache
79       * <p>
80       * @param d
81       *            The new useLateral value
82       */
83      void setUseLateral( boolean d );
84  
85      /**
86       * Gets the useLateral attribute of the ICompositeCacheAttributes object
87       * <p>
88       * @return The useLateral value
89       */
90      boolean isUseLateral();
91  
92      /**
93       * Sets whether the cache is remote enabled
94       * <p>
95       * @param isRemote
96       *            The new useRemote value
97       */
98      void setUseRemote( boolean isRemote );
99  
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 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 }