use of io.atomix.core.multimap.AsyncAtomicMultimap in project atomix by atomix.
the class DefaultAtomicMultimapBuilder method buildAsync.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<AtomicMultimap<K, V>> buildAsync() {
return newProxy(AtomicMultimapService.class, new ServiceConfig()).thenCompose(proxy -> new AtomicMultimapProxy(proxy, managementService.getPrimitiveRegistry()).connect()).thenApply(rawMultimap -> {
Serializer serializer = serializer();
AsyncAtomicMultimap<K, V> multimap = new TranscodingAsyncAtomicMultimap<>(rawMultimap, key -> BaseEncoding.base16().encode(serializer.encode(key)), string -> serializer.decode(BaseEncoding.base16().decode(string)), value -> serializer.encode(value), bytes -> serializer.decode(bytes));
if (config.getCacheConfig().isEnabled()) {
multimap = new CachingAsyncAtomicMultimap<>(multimap, config.getCacheConfig());
}
return multimap.sync();
});
}
Aggregations