public static <V> Task<V> get(String key, Class<V> valueType) { return Task.async( "Get PlanLocal", context -> { long id = context.getPlanId(); final Map<String, Object> map = _planLocalMap.get(id); return Promises.value(map != null ? (V) map.get(key) : null); }); }
public static <V> Task<Void> put(String key, V value) { return Task.async( "Put PlanLocal", context -> { long id = context.getPlanId(); final Map<String, Object> map = _planLocalMap.computeIfAbsent(id, k -> new HashMap()); map.put(key, value); return Promises.value(null); }); }
public static Task<Void> remove(String key) { return Task.async( "Remove PlanLocal", context -> { long id = context.getPlanId(); _planLocalMap.computeIfPresent( id, (k, v) -> { v.remove(key); return v.isEmpty() ? null : v; }); return Promises.value(null); }); }