View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.cache;
18  
19  import org.apache.jetspeed.request.RequestContext;
20  
21  /***
22   * <p>
23   *  Provides interface to Jetspeed for cache related activities
24   *  Abstraction around actual cache implementation
25   * </p>
26   * 
27   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
28   * @version $Id: $
29   */
30  public interface JetspeedCache
31  {
32      /***
33       * Retrieve an object from the cache
34       * 
35       * @param key The key used to find the object
36       * @return the found object or null
37       */
38      CacheElement get(Object key);
39      
40      /***
41       * clear all content in the cache
42       *
43       */
44      void clear();
45      
46      /***
47       * Put an object into the cache, adding it, or replacing if exists
48       * @param object
49       */
50      void put(CacheElement object);
51      
52      /***
53       * Create a cached element 
54       * 
55       * @param key
56       * @param content
57       * @return
58       */
59      CacheElement createElement(Object key, Object content);
60      
61      boolean isKeyInCache(Object key);
62      
63      /***
64       * Remove an object from the cache
65       * @param key
66       * @return true if the object was removed, false otherwise
67       */
68      boolean remove(Object key);
69      
70      /***
71       * Remove object from cache, do not notify listeners
72       * 
73       * @param key
74       * @return trie if the object was removed, false otherwise
75       */
76      boolean removeQuiet(Object key);
77      
78      /***
79       * 
80       * @return the default idle time in seconds for this cache
81       */
82      int getTimeToIdleSeconds();
83      
84      /***
85       * 
86       * @return the default idle time in seconds for this cache
87       */
88      int getTimeToLiveSeconds();
89  
90      /***
91       * Evict all cached content for the given username 
92       * 
93       * @param username unique user identifier
94       */
95      void evictContentForUser(String username);
96  
97      /***
98       * Evict all cached content for the given session identifier 
99       * 
100      * @param sessionid unique session identifier
101      */    
102     void evictContentForSession(String sessionId);
103     
104     /***
105      * Create a portlet content cache key based on dynamic request context information and a window id
106      * 
107      * @param rc
108      * @param windowId
109      * @since 2.1.2
110      * @return
111      */
112     ContentCacheKey createCacheKey(RequestContext rc, String windowId);
113     
114     /***
115      * Add a cache listener for supported cache events, either for local or remote cache events
116      * 
117      * @param listener
118      * @param local if true, listen to local events, if false, listen to remote 
119      */         
120     void addEventListener(JetspeedCacheEventListener listener, boolean local);
121     
122     void removeEventListener(JetspeedCacheEventListener listener, boolean local);
123 }