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.cache.PortalCacheHelperUtil;
020 import com.liferay.portal.kernel.util.StringUtil;
021
022
025 public class PortalPreferencesWrapperCacheUtil {
026
027 public static final String CACHE_NAME =
028 PortalPreferencesWrapperCacheUtil.class.getName();
029
030 public static PortalPreferencesWrapper get(long ownerId, int ownerType) {
031 String cacheKey = _getCacheKey(ownerId, 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 = _getCacheKey(ownerId, ownerType);
041
042 PortalCacheHelperUtil.putWithoutReplicator(
043 _portalPreferencesWrapperPortalCache, cacheKey,
044 portalPreferencesWrapper);
045 }
046
047 public static void remove(long ownerId, int ownerType) {
048 String cacheKey = _getCacheKey(ownerId, ownerType);
049
050 _portalPreferencesWrapperPortalCache.remove(cacheKey);
051 }
052
053 private static String _getCacheKey(long ownerId, int ownerType) {
054 String cacheKey = StringUtil.toHexString(ownerId);
055
056 cacheKey = cacheKey.concat(StringUtil.toHexString(ownerType));
057
058 return cacheKey;
059 }
060
061 private static final PortalCache<String, PortalPreferencesWrapper>
062 _portalPreferencesWrapperPortalCache = MultiVMPoolUtil.getPortalCache(
063 CACHE_NAME);
064
065 }