001
014
015 package com.liferay.portlet.calendar.service.impl;
016
017 import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
018 import com.liferay.portal.kernel.cache.PortalCache;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.util.StringUtil;
021 import com.liferay.portlet.calendar.model.CalEvent;
022
023 import java.util.List;
024 import java.util.Map;
025 import java.util.concurrent.ConcurrentHashMap;
026
027
031 public class CalEventLocalUtil {
032
033 protected static void clearEventsPool(long groupId) {
034 String key = _encodeKey(groupId);
035
036 _portalCache.remove(key);
037 }
038
039 protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
040 String key = _encodeKey(groupId);
041
042 Map <String, List<CalEvent>> eventsPool =
043 (Map<String, List<CalEvent>>)_portalCache.get(key);
044
045 if (eventsPool == null) {
046 eventsPool = new ConcurrentHashMap<String, List<CalEvent>>();
047
048 _portalCache.put(key, eventsPool);
049 }
050
051 return eventsPool;
052 }
053
054 private static String _encodeKey(long groupId) {
055 return _CACHE_NAME.concat(StringPool.POUND).concat(
056 StringUtil.toHexString(groupId));
057 }
058
059 private static final String _CACHE_NAME = CalEventLocalUtil.class.getName();
060
061 private static PortalCache _portalCache = MultiVMPoolUtil.getCache(
062 _CACHE_NAME);
063
064 }