1
14
15 package com.liferay.portlet.calendar.service.impl;
16
17 import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
18 import com.liferay.portal.kernel.cache.PortalCache;
19 import com.liferay.portal.kernel.util.StringPool;
20 import com.liferay.portal.kernel.util.StringUtil;
21 import com.liferay.portlet.calendar.model.CalEvent;
22
23 import java.util.List;
24 import java.util.Map;
25 import java.util.concurrent.ConcurrentHashMap;
26
27
33 public class CalEventLocalUtil {
34
35 public static final String CACHE_NAME = CalEventLocalUtil.class.getName();
36
37 protected static void clearEventsPool(long groupId) {
38 String key = _encodeKey(groupId);
39
40 _portalCache.remove(key);
41 }
42
43 protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
44 String key = _encodeKey(groupId);
45
46 Map <String, List<CalEvent>> eventsPool =
47 (Map<String, List<CalEvent>>)_portalCache.get(key);
48
49 if (eventsPool == null) {
50 eventsPool = new ConcurrentHashMap<String, List<CalEvent>>();
51
52 _portalCache.put(key, eventsPool);
53 }
54
55 return eventsPool;
56 }
57
58 private static String _encodeKey(long groupId) {
59 return CACHE_NAME.concat(StringPool.POUND).concat(
60 StringUtil.toHexString(groupId));
61 }
62
63 private static PortalCache _portalCache = MultiVMPoolUtil.getCache(
64 CACHE_NAME);
65
66 }