All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.fluxcapacitor.javaclient.keyvalue.client.InMemoryKeyValueClient Maven / Gradle / Ivy

There is a newer version: 0.1015.0
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy