View Javadoc
1   package org.apache.commons.jcs.access.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 org.apache.commons.jcs.access.exception.CacheException;
23  import org.apache.commons.jcs.engine.behavior.ICompositeCacheAttributes;
24  import org.apache.commons.jcs.engine.behavior.IElementAttributes;
25  import org.apache.commons.jcs.engine.stats.behavior.ICacheStats;
26  
27  /**
28   * ICacheAccessManagement defines the methods for cache management, cleanup and shutdown.
29   */
30  public interface ICacheAccessManagement
31  {
32      /**
33       * Dispose this region. Flushes objects to and closes auxiliary caches. This is a shutdown
34       * command!
35       * <p>
36       * To simply remove all elements from the region use clear().
37       */
38      void dispose();
39  
40      /**
41       * Removes all of the elements from a region.
42       * <p>
43       * @throws CacheException
44       */
45      void clear() throws CacheException;
46  
47      /**
48       * GetElementAttributes will return an attribute object describing the current attributes
49       * associated with the object name. If no name parameter is available, the attributes for the
50       * region will be returned. The name object must override the Object.equals and Object.hashCode
51       * methods.
52       * <p>
53       * @return The elementAttributes value
54       * @throws CacheException
55       */
56      IElementAttributes getDefaultElementAttributes()
57          throws CacheException;
58  
59      /**
60       * This method is does not reset the attributes for items already in the cache. It could
61       * potentially do this for items in memory, and maybe on disk (which would be slow) but not
62       * remote items. Rather than have unpredictable behavior, this method just sets the default
63       * attributes. Items subsequently put into the cache will use these defaults if they do not
64       * specify specific attributes.
65       * <p>
66       * @param attr the default attributes.
67       * @throws CacheException if something goes wrong.
68       */
69      void setDefaultElementAttributes( IElementAttributes attr ) throws CacheException;
70  
71      /**
72       * Gets the ICompositeCacheAttributes of the cache region
73       * <p>
74       * @return ICompositeCacheAttributes
75       */
76      ICompositeCacheAttributes getCacheAttributes();
77  
78      /**
79       * Sets the ICompositeCacheAttributes of the cache region
80       * <p>
81       * @param cattr The new ICompositeCacheAttribute value
82       */
83      void setCacheAttributes( ICompositeCacheAttributes cattr );
84  
85      /**
86       * This instructs the memory cache to remove the <i>numberToFree</i> according to its eviction
87       * policy. For example, the LRUMemoryCache will remove the <i>numberToFree</i> least recently
88       * used items. These will be spooled to disk if a disk auxiliary is available.
89       * <p>
90       * @param numberToFree
91       * @return the number that were removed. if you ask to free 5, but there are only 3, you will
92       *         get 3.
93       * @throws CacheException
94       */
95      int freeMemoryElements( int numberToFree )
96          throws CacheException;
97  
98      /**
99       * This returns the ICacheStats object with information on this region and its auxiliaries.
100      * <p>
101      * This data can be formatted as needed.
102      * <p>
103      * @return ICacheStats
104      */
105     ICacheStats getStatistics();
106 
107     /**
108      * @return A String version of the stats.
109      */
110     String getStats();
111 }