1
19
20 package com.liferay.portlet.calendar.service.impl;
21
22 import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
23 import com.liferay.portal.kernel.cache.PortalCache;
24 import com.liferay.portal.kernel.util.StringPool;
25 import com.liferay.portlet.calendar.model.CalEvent;
26
27 import java.util.List;
28 import java.util.Map;
29 import java.util.concurrent.ConcurrentHashMap;
30
31
38 public class CalEventLocalUtil {
39
40 public static final String CACHE_NAME = CalEventLocalUtil.class.getName();
41
42 protected static void clearEventsPool(long groupId) {
43 String key = _encodeKey(groupId);
44
45 _cache.remove(key);
46 }
47
48 protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
49 String key = _encodeKey(groupId);
50
51 Map <String, List<CalEvent>> eventsPool =
52 (Map<String, List<CalEvent>>)MultiVMPoolUtil.get(_cache, key);
53
54 if (eventsPool == null) {
55 eventsPool = new ConcurrentHashMap<String, List<CalEvent>>();
56
57 MultiVMPoolUtil.put(_cache, key, eventsPool);
58 }
59
60 return eventsPool;
61 }
62
63 private static String _encodeKey(long groupId) {
64 StringBuilder sb = new StringBuilder();
65
66 sb.append(CACHE_NAME);
67 sb.append(StringPool.POUND);
68 sb.append(groupId);
69
70 return sb.toString();
71 }
72
73 private static PortalCache _cache = MultiVMPoolUtil.getCache(CACHE_NAME);
74
75 }