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