001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.cache;
016    
017    import com.liferay.portal.kernel.cache.PortalCache;
018    import com.liferay.portal.kernel.cache.PortalCacheManager;
019    import com.liferay.portal.kernel.cache.SingleVMPool;
020    
021    import java.io.Serializable;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Michael Young
026     */
027    public class SingleVMPoolImpl implements SingleVMPool {
028    
029            public void clear() {
030                    _portalCacheManager.clearAll();
031            }
032    
033            public void clear(String name) {
034                    PortalCache portalCache = getCache(name);
035    
036                    portalCache.removeAll();
037            }
038    
039            public Object get(String name, String key) {
040                    PortalCache portalCache = getCache(name);
041    
042                    return portalCache.get(key);
043            }
044    
045            /**
046             * @deprecated
047             */
048            public Object get(PortalCache portalCache, String key) {
049                    return portalCache.get(key);
050            }
051    
052            public PortalCache getCache(String name) {
053                    return _portalCacheManager.getCache(name);
054            }
055    
056            public PortalCache getCache(String name, boolean blocking) {
057                    return _portalCacheManager.getCache(name, blocking);
058            }
059    
060            public void put(String name, String key, Object obj) {
061                    PortalCache portalCache = getCache(name);
062    
063                    portalCache.put(key, obj);
064            }
065    
066            /**
067             * @deprecated
068             */
069            public void put(PortalCache portalCache, String key, Object obj) {
070                    portalCache.put(key, obj);
071            }
072    
073            /**
074             * @deprecated
075             */
076            public void put(
077                    PortalCache portalCache, String key, Object obj, int timeToLive) {
078    
079                    portalCache.put(key, obj, timeToLive);
080            }
081    
082            public void put(String name, String key, Serializable obj) {
083                    PortalCache portalCache = getCache(name);
084    
085                    portalCache.put(key, obj);
086            }
087    
088            /**
089             * @deprecated
090             */
091            public void put(PortalCache portalCache, String key, Serializable obj) {
092                    portalCache.put(key, obj);
093            }
094    
095            /**
096             * @deprecated
097             */
098            public void put(
099                    PortalCache portalCache, String key, Serializable obj, int timeToLive) {
100    
101                    portalCache.put(key, obj, timeToLive);
102            }
103    
104            public void remove(String name, String key) {
105                    PortalCache portalCache = getCache(name);
106    
107                    portalCache.remove(key);
108            }
109    
110            /**
111             * @deprecated
112             */
113            public void remove(PortalCache portalCache, String key) {
114                    portalCache.remove(key);
115            }
116    
117            public void removeCache(String name) {
118                    _portalCacheManager.removeCache(name);
119            }
120    
121            public void setPortalCacheManager(PortalCacheManager portalCacheManager) {
122                    _portalCacheManager = portalCacheManager;
123            }
124    
125            private PortalCacheManager _portalCacheManager;
126    
127    }