1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.cache;
16  
17  import com.liferay.portal.kernel.cache.PortalCache;
18  import com.liferay.portal.kernel.cache.PortalCacheManager;
19  import com.liferay.portal.kernel.cache.SingleVMPool;
20  
21  import java.io.Serializable;
22  
23  /**
24   * <a href="SingleVMPoolImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   * @author Michael Young
28   */
29  public class SingleVMPoolImpl implements SingleVMPool {
30  
31      public void clear() {
32          _portalCacheManager.clearAll();
33      }
34  
35      public void clear(String name) {
36          PortalCache portalCache = getCache(name);
37  
38          portalCache.removeAll();
39      }
40  
41      public Object get(String name, String key) {
42          PortalCache portalCache = getCache(name);
43  
44          return portalCache.get(key);
45      }
46  
47      /**
48       * @deprecated
49       */
50      public Object get(PortalCache portalCache, String key) {
51          return portalCache.get(key);
52      }
53  
54      public PortalCache getCache(String name) {
55          return _portalCacheManager.getCache(name);
56      }
57  
58      public PortalCache getCache(String name, boolean blocking) {
59          return _portalCacheManager.getCache(name, blocking);
60      }
61  
62      public void put(String name, String key, Object obj) {
63          PortalCache portalCache = getCache(name);
64  
65          portalCache.put(key, obj);
66      }
67  
68      /**
69       * @deprecated
70       */
71      public void put(PortalCache portalCache, String key, Object obj) {
72          portalCache.put(key, obj);
73      }
74  
75      /**
76       * @deprecated
77       */
78      public void put(
79          PortalCache portalCache, String key, Object obj, int timeToLive) {
80  
81          portalCache.put(key, obj, timeToLive);
82      }
83  
84      public void put(String name, String key, Serializable obj) {
85          PortalCache portalCache = getCache(name);
86  
87          portalCache.put(key, obj);
88      }
89  
90      /**
91       * @deprecated
92       */
93      public void put(PortalCache portalCache, String key, Serializable obj) {
94          portalCache.put(key, obj);
95      }
96  
97      /**
98       * @deprecated
99       */
100     public void put(
101         PortalCache portalCache, String key, Serializable obj, int timeToLive) {
102 
103         portalCache.put(key, obj, timeToLive);
104     }
105 
106     public void remove(String name, String key) {
107         PortalCache portalCache = getCache(name);
108 
109         portalCache.remove(key);
110     }
111 
112     /**
113      * @deprecated
114      */
115     public void remove(PortalCache portalCache, String key) {
116         portalCache.remove(key);
117     }
118 
119     public void setPortalCacheManager(PortalCacheManager portalCacheManager) {
120         _portalCacheManager = portalCacheManager;
121     }
122 
123     private PortalCacheManager _portalCacheManager;
124 
125 }