001    /**
002     * Copyright (c) 2000-2013 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.portlet;
016    
017    import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
018    import com.liferay.portal.kernel.cache.PortalCache;
019    import com.liferay.portal.kernel.util.StringUtil;
020    
021    /**
022     * @author Shuyang Zhou
023     */
024    public class PortalPreferencesWrapperCacheUtil {
025    
026            public static final String CACHE_NAME =
027                    PortalPreferencesWrapperCacheUtil.class.getName();
028    
029            public static PortalPreferencesWrapper get(long ownerId, int ownerType) {
030                    String cacheKey = StringUtil.toHexString(ownerId).concat(
031                            StringUtil.toHexString(ownerType));
032    
033                    return _portalPreferencesWrapperPortalCache.get(cacheKey);
034            }
035    
036            public static void put(
037                    long ownerId, int ownerType,
038                    PortalPreferencesWrapper portalPreferencesWrapper) {
039    
040                    String cacheKey = StringUtil.toHexString(ownerId).concat(
041                            StringUtil.toHexString(ownerType));
042    
043                    _portalPreferencesWrapperPortalCache.put(
044                            cacheKey, portalPreferencesWrapper);
045            }
046    
047            public static void remove(long ownerId, int ownerType) {
048                    String cacheKey = StringUtil.toHexString(ownerId).concat(
049                            StringUtil.toHexString(ownerType));
050    
051                    _portalPreferencesWrapperPortalCache.remove(cacheKey);
052            }
053    
054            private static PortalCache<String, PortalPreferencesWrapper>
055                    _portalPreferencesWrapperPortalCache = MultiVMPoolUtil.getCache(
056                            CACHE_NAME);
057    
058    }