Skip to content
Snippets Groups Projects
Commit c51a87e5 authored by srosse's avatar srosse
Browse files

OO-948: use "putIfAbsent" instead of doInSync for the calendar's cache

parent 95abc52e
No related branches found
No related tags found
No related merge requests found
......@@ -164,25 +164,20 @@ public class ICalFileCalendarManager extends BasicManager implements CalendarMan
String key = getKeyFor(type, calendarID);
Kalendar cal = calendarCache.get(key);
if(cal == null) {
//o_clusterOK by:cg
OLATResourceable calOres = OresHelper.createOLATResourceableType(getKeyFor(type,calendarID));
cal = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync( calOres, new SyncerCallback<Kalendar>() {
public Kalendar execute() {
return getCalendarFromCache(type, calendarID);
}
});
cal = getCalendarFromCache(type, calendarID);
}
return cal;
}
private Kalendar getCalendarFromCache(final String callType, final String callCalendarID) {
String calKey = getKeyFor(callType,callCalendarID);
OLATResourceable calOres = OresHelper.createOLATResourceableType(calKey);
CoordinatorManager.getInstance().getCoordinator().getSyncer().assertAlreadyDoInSyncFor(calOres);
String calKey = getKeyFor(callType,callCalendarID);
Kalendar cal = calendarCache.get(calKey);
if (cal == null) {
cal = loadOrCreateCalendar(callType, callCalendarID);
calendarCache.put(calKey, cal);
Kalendar cacheCal = calendarCache.putIfAbsent(calKey, cal);
if(cacheCal != null) {
cal = cacheCal;
}
}
return cal;
}
......
......@@ -89,6 +89,8 @@ public interface CacheWrapper<U, V extends Serializable> {
*/
public V put(U key, V value);
public V putIfAbsent(U key, V value);
/**
* In the case of distributed cache, the list can be partial and
* you must carefully setup your cache.
......
......@@ -102,4 +102,11 @@ public class InfinispanCacheWrapper<U,V extends Serializable> implements CacheWr
V oldOne = cache.put(key, value);
return oldOne;
}
@Override
public V putIfAbsent(U key, V value) {
return cache.putIfAbsent(key, value);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment