View Javadoc

1   package org.apache.jcs.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 minimla behavior for the Cache Configuration settings.
26   */
27  public interface ICompositeCacheAttributes
28      extends Serializable
29  {
30      /*** Items will only go to disk when the memory limit is reached. This is the default. */
31      public static final short DISK_USAGE_PATTERN_SWAP = 0;
32  
33      /***
34       * Items will go to disk on a normal put. If The disk usage pattern is UPDATE, the swap will be
35       * disabled.
36       */
37      public static final short DISK_USAGE_PATTERN_UPDATE = 1;
38  
39      /***
40       * SetMaxObjects is used to set the attribute to determine the maximum
41       * number of objects allowed in the memory cache. If the max number of
42       * objects or the cache size is set, the default for the one not set is
43       * ignored. If both are set, both are used to determine the capacity of the
44       * cache, i.e., object will be removed from the cache if either limit is
45       * reached. TODO: move to MemoryCache config file.
46       * <p>
47       * @param size
48       *            The new maxObjects value
49       */
50      public void setMaxObjects( int size );
51  
52      /***
53       * Gets the maxObjects attribute of the ICompositeCacheAttributes object
54       * <p>
55       * @return The maxObjects value
56       */
57      public int getMaxObjects();
58  
59      /***
60       * Sets the useDisk attribute of the ICompositeCacheAttributes object
61       * <p>
62       * @param useDisk
63       *            The new useDisk value
64       */
65      public void setUseDisk( boolean useDisk );
66  
67      /***
68       * Gets the useDisk attribute of the ICompositeCacheAttributes object
69       * <p>
70       * @return The useDisk value
71       */
72      public boolean getUseDisk();
73  
74      /***
75       * set whether the cache should use a lateral cache
76       * <p>
77       * @param d
78       *            The new useLateral value
79       */
80      public void setUseLateral( boolean d );
81  
82      /***
83       * Gets the useLateral attribute of the ICompositeCacheAttributes object
84       * <p>
85       * @return The useLateral value
86       */
87      public boolean getUseLateral();
88  
89      /***
90       * Sets whether the cache is remote enabled
91       * <p>
92       * @param isRemote
93       *            The new useRemote value
94       */
95      public void setUseRemote( boolean isRemote );
96  
97      /***
98       * returns whether the cache is remote enabled
99       * <p>
100      * @return The useRemote value
101      */
102     public boolean getUseRemote();
103 
104     /***
105      * Sets the name of the cache, referenced by the appropriate manager.
106      * <p>
107      * @param s
108      *            The new cacheName value
109      */
110     public void setCacheName( String s );
111 
112     /***
113      * Gets the cacheName attribute of the ICompositeCacheAttributes object
114      * <p>
115      * @return The cacheName value
116      */
117     public String getCacheName();
118 
119     /***
120      * Sets the name of the MemoryCache, referenced by the appropriate manager.
121      * TODO: create a separate memory cache attribute class.
122      * <p>
123      * @param s
124      *            The new memoryCacheName value
125      */
126     public void setMemoryCacheName( String s );
127 
128     /***
129      * Gets the memoryCacheName attribute of the ICompositeCacheAttributes
130      * object
131      * <p>
132      * @return The memoryCacheName value
133      */
134     public String getMemoryCacheName();
135 
136     /***
137      * Whether the memory cache should perform background memory shrinkage.
138      * <p>
139      * @param useShrinker
140      *            The new UseMemoryShrinker value
141      */
142     public void setUseMemoryShrinker( boolean useShrinker );
143 
144     /***
145      * Whether the memory cache should perform background memory shrinkage.
146      * <p>
147      * @return The UseMemoryShrinker value
148      */
149     public boolean getUseMemoryShrinker();
150 
151     /***
152      * If UseMemoryShrinker is true the memory cache should auto-expire elements
153      * to reclaim space.
154      * <p>
155      * @param seconds
156      *            The new MaxMemoryIdleTimeSeconds value
157      */
158     public void setMaxMemoryIdleTimeSeconds( long seconds );
159 
160     /***
161      * If UseMemoryShrinker is true the memory cache should auto-expire elements
162      * to reclaim space.
163      * <p>
164      * @return The MaxMemoryIdleTimeSeconds value
165      */
166     public long getMaxMemoryIdleTimeSeconds();
167 
168     /***
169      * If UseMemoryShrinker is true the memory cache should auto-expire elements
170      * to reclaim space. This sets the shrinker interval.
171      * <p>
172      * @param seconds
173      *            The new ShrinkerIntervalSeconds value
174      */
175     public void setShrinkerIntervalSeconds( long seconds );
176 
177     /***
178      * If UseMemoryShrinker is true the memory cache should auto-expire elements
179      * to reclaim space. This gets the shrinker interval.
180      * <p>
181      * @return The ShrinkerIntervalSeconds value
182      */
183     public long getShrinkerIntervalSeconds();
184 
185     /***
186      * If UseMemoryShrinker is true the memory cache should auto-expire elements
187      * to reclaim space. This sets the maximum number of items to spool per run.
188      * <p>
189      * @param maxSpoolPerRun
190      *            The new maxSpoolPerRun value
191      */
192     public void setMaxSpoolPerRun( int maxSpoolPerRun );
193 
194     /***
195      * If UseMemoryShrinker is true the memory cache should auto-expire elements
196      * to reclaim space. This gets the maximum number of items to spool per run.
197      * <p>
198      * @return The maxSpoolPerRun value
199      */
200     public int getMaxSpoolPerRun();
201 
202     /***
203      * Clones the attributes.
204      * <p>
205      * @return a new object with the same settings.
206      */
207     public ICompositeCacheAttributes copy();
208 
209     /***
210      * By default this is SWAP_ONLY.
211      * <p>
212      * @param diskUsagePattern The diskUsagePattern to set.
213      */
214     public void setDiskUsagePattern( short diskUsagePattern );
215 
216     /***
217      * Translates the name to the disk usage pattern short value.
218      * <p>
219      * The allowed values are SWAP and UPDATE.
220      * <p>
221      * @param diskUsagePatternName The diskUsagePattern to set.
222      */
223     public void setDiskUsagePatternName( String diskUsagePatternName );
224 
225     /***
226      * @return Returns the diskUsagePattern.
227      */
228     public short getDiskUsagePattern();
229 }