001
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
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 = _getCacheKey(ownerId, ownerType);
031
032 return _portalPreferencesWrapperPortalCache.get(cacheKey);
033 }
034
035 public static void put(
036 long ownerId, int ownerType,
037 PortalPreferencesWrapper portalPreferencesWrapper) {
038
039 String cacheKey = _getCacheKey(ownerId, ownerType);
040
041 _portalPreferencesWrapperPortalCache.putQuiet(
042 cacheKey, portalPreferencesWrapper);
043 }
044
045 public static void remove(long ownerId, int ownerType) {
046 String cacheKey = _getCacheKey(ownerId, ownerType);
047
048 _portalPreferencesWrapperPortalCache.remove(cacheKey);
049 }
050
051 private static String _getCacheKey(long ownerId, int ownerType) {
052 String cacheKey = StringUtil.toHexString(ownerId);
053
054 cacheKey = cacheKey.concat(StringUtil.toHexString(ownerType));
055
056 return cacheKey;
057 }
058
059 private static final PortalCache<String, PortalPreferencesWrapper>
060 _portalPreferencesWrapperPortalCache = MultiVMPoolUtil.getCache(
061 CACHE_NAME);
062
063 }