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.portlet.calendar.model.CalEvent;
21
22 import java.util.List;
23 import java.util.Map;
24 import java.util.concurrent.ConcurrentHashMap;
25
26
32 public class CalEventLocalUtil {
33
34 public static final String CACHE_NAME = CalEventLocalUtil.class.getName();
35
36 protected static void clearEventsPool(long groupId) {
37 String key = _encodeKey(groupId);
38
39 _cache.remove(key);
40 }
41
42 protected static Map<String, List<CalEvent>> getEventsPool(long groupId) {
43 String key = _encodeKey(groupId);
44
45 Map <String, List<CalEvent>> eventsPool =
46 (Map<String, List<CalEvent>>)_cache.get(key);
47
48 if (eventsPool == null) {
49 eventsPool = new ConcurrentHashMap<String, List<CalEvent>>();
50
51 _cache.put(key, eventsPool);
52 }
53
54 return eventsPool;
55 }
56
57 private static String _encodeKey(long groupId) {
58 return CACHE_NAME.concat(StringPool.POUND).concat(
59 String.valueOf(groupId));
60 }
61
62 private static PortalCache _cache = MultiVMPoolUtil.getCache(CACHE_NAME);
63
64 }