001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }