io.fluxcapacitor.javaclient.keyvalue.client.InMemoryKeyValueClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
Default Java client library for interfacing with Flux Capacitor.
package io.fluxcapacitor.javaclient.keyvalue.client;
import io.fluxcapacitor.common.Awaitable;
import io.fluxcapacitor.common.api.Data;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class InMemoryKeyValueClient implements KeyValueClient {
private final Map> values;
public InMemoryKeyValueClient() {
this(new ConcurrentHashMap<>());
}
protected InMemoryKeyValueClient(Map> map) {
values = map;
}
@Override
public Awaitable putValue(String key, Data value) {
values.put(key, value);
return Awaitable.ready();
}
@Override
public Data getValue(String key) {
return values.get(key);
}
@Override
public Awaitable deleteValue(String key) {
values.remove(key);
return Awaitable.ready();
}
}