1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.cache;
21  
22  import com.liferay.portal.kernel.cache.PortalCache;
23  import com.liferay.portal.kernel.cache.PortalCacheManager;
24  import com.liferay.portal.kernel.cache.SingleVMPool;
25  
26  import java.io.Serializable;
27  
28  /**
29   * <a href="SingleVMPoolImpl.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   * @author Michael Young
33   *
34   */
35  public class SingleVMPoolImpl implements SingleVMPool {
36  
37      public void clear() {
38          _portalCacheManager.clearAll();
39      }
40  
41      public void clear(String name) {
42          PortalCache portalCache = getCache(name);
43  
44          portalCache.removeAll();
45      }
46  
47      public Object get(String name, String key) {
48          PortalCache portalCache = getCache(name);
49  
50          return get(portalCache, key);
51      }
52  
53      public Object get(PortalCache portalCache, String key) {
54          return portalCache.get(key);
55      }
56  
57      public PortalCache getCache(String name) {
58          return _portalCacheManager.getCache(name);
59      }
60  
61      public PortalCache getCache(String name, boolean blocking) {
62          return _portalCacheManager.getCache(name, blocking);
63      }
64  
65      public void put(String name, String key, Object obj) {
66          PortalCache portalCache = getCache(name);
67  
68          put(portalCache, key, obj);
69      }
70  
71      public void put(PortalCache portalCache, String key, Object obj) {
72          portalCache.put(key, obj);
73      }
74  
75      public void put(
76          PortalCache portalCache, String key, Object obj, int timeToLive) {
77  
78          portalCache.put(key, obj, timeToLive);
79      }
80  
81      public void put(String name, String key, Serializable obj) {
82          PortalCache portalCache = getCache(name);
83  
84          put(portalCache, key, obj);
85      }
86  
87      public void put(PortalCache portalCache, String key, Serializable obj) {
88          portalCache.put(key, obj);
89      }
90  
91      public void put(
92          PortalCache portalCache, String key, Serializable obj, int timeToLive) {
93  
94          portalCache.put(key, obj, timeToLive);
95      }
96  
97      public void remove(String name, String key) {
98          PortalCache portalCache = getCache(name);
99  
100         remove(portalCache, key);
101     }
102 
103     public void remove(PortalCache portalCache, String key) {
104         portalCache.remove(key);
105     }
106 
107     public void setPortalCacheManager(PortalCacheManager portalCacheManager) {
108         _portalCacheManager = portalCacheManager;
109     }
110 
111     private PortalCacheManager _portalCacheManager;
112 
113 }