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.portlet.calendar.model.CalEvent;
021
022 import java.util.List;
023 import java.util.Map;
024 import java.util.concurrent.ConcurrentHashMap;
025
026
030 public class CalEventLocalUtil {
031
032 public static final String CACHE_NAME = CalEventLocalUtil.class.getName();
033
034 protected static void clearEventsPool(long groupId) {
035 String key = _encodeKey(groupId);
036
037 _portalCache.remove(key);
038 }
039
040 protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
041 String key = _encodeKey(groupId);
042
043 Map <String, List<CalEvent>> eventsPool =
044 (Map<String, List<CalEvent>>)_portalCache.get(key);
045
046 if (eventsPool == null) {
047 eventsPool = new ConcurrentHashMap<String, List<CalEvent>>();
048
049 _portalCache.put(key, eventsPool);
050 }
051
052 return eventsPool;
053 }
054
055 private static String _encodeKey(long groupId) {
056 return CACHE_NAME.concat(StringPool.POUND).concat(
057 String.valueOf(groupId));
058 }
059
060 private static PortalCache _portalCache = MultiVMPoolUtil.getCache(
061 CACHE_NAME);
062
063 }