Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.infinispan.hotrod.HotRodMutinyCache Maven / Gradle / Ivy
package org.infinispan.hotrod;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import org.infinispan.api.common.CacheEntry;
import org.infinispan.api.common.CacheEntryVersion;
import org.infinispan.api.common.CacheOptions;
import org.infinispan.api.common.CacheWriteOptions;
import org.infinispan.api.common.events.cache.CacheEntryEvent;
import org.infinispan.api.common.events.cache.CacheEntryEventType;
import org.infinispan.api.common.events.cache.CacheListenerOptions;
import org.infinispan.api.common.process.CacheEntryProcessorResult;
import org.infinispan.api.configuration.CacheConfiguration;
import org.infinispan.api.mutiny.MutinyCache;
import org.infinispan.api.mutiny.MutinyCacheEntryProcessor;
import org.infinispan.api.mutiny.MutinyQuery;
import org.infinispan.api.mutiny.MutinyStreamingCache;
import org.infinispan.hotrod.impl.cache.RemoteCache;
import java.util.Map;
import java.util.Set;
/**
* @since 14.0
**/
public class HotRodMutinyCache implements MutinyCache {
private final HotRod hotrod;
private final RemoteCache remoteCache;
HotRodMutinyCache(HotRod hotrod, RemoteCache remoteCache) {
this.hotrod = hotrod;
this.remoteCache = remoteCache;
}
@Override
public String name() {
return remoteCache.getName();
}
@Override
public Uni configuration() {
return Uni.createFrom().completionStage(remoteCache.configuration());
}
@Override
public HotRodMutinyContainer container() {
return hotrod.mutiny();
}
@Override
public Uni get(K key, CacheOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.get(key, options));
}
@Override
public Uni> getEntry(K key, CacheOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.getEntry(key, options));
}
@Override
public Uni> putIfAbsent(K key, V value, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.putIfAbsent(key, value, options));
}
@Override
public Uni setIfAbsent(K key, V value, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.setIfAbsent(key, value, options));
}
@Override
public Uni> put(K key, V value, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.put(key, value, options));
}
@Override
public Uni set(K key, V value, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.set(key, value, options));
}
@Override
public Uni remove(K key, CacheOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.remove(key, options));
}
@Override
public Uni> getAndRemove(K key, CacheOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.getAndRemove(key, options));
}
@Override
public Multi keys(CacheOptions options) {
return Multi.createFrom().publisher(remoteCache.keys(options));
}
@Override
public Multi> entries(CacheOptions options) {
return Multi.createFrom().publisher(remoteCache.entries(options));
}
@Override
public Multi> getAll(Set keys, CacheOptions options) {
return Multi.createFrom().publisher(remoteCache.getAll(keys, options));
}
@Override
public Multi> getAll(CacheOptions options, K... keys) {
return Multi.createFrom().publisher(remoteCache.getAll(options, keys));
}
@Override
public Uni putAll(Multi> entries, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.putAll(entries.convert().toPublisher(), options));
}
@Override
public Uni putAll(Map map, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.putAll(map, options));
}
@Override
public Uni replace(K key, V value, CacheEntryVersion version, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.replace(key, value, version, options));
}
@Override
public Uni> getOrReplaceEntry(K key, V value, CacheEntryVersion version, CacheWriteOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.getOrReplaceEntry(key, value, version, options));
}
@Override
public Multi removeAll(Set keys, CacheWriteOptions options) {
return Multi.createFrom().publisher(remoteCache.removeAll(keys, options));
}
@Override
public Multi removeAll(Multi keys, CacheWriteOptions options) {
return Multi.createFrom().publisher(remoteCache.removeAll(keys.convert().toPublisher(), options));
}
@Override
public Multi> getAndRemoveAll(Multi keys, CacheWriteOptions options) {
return Multi.createFrom().publisher(remoteCache.getAndRemoveAll(keys.convert().toPublisher(), options));
}
@Override
public Uni estimateSize(CacheOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.estimateSize(options));
}
@Override
public Uni clear(CacheOptions options) {
return Uni.createFrom().completionStage(() -> remoteCache.clear(options));
}
@Override
public MutinyQuery query(String query, CacheOptions options) {
return new HotRodMutinyQuery(query, options);
}
@Override
public Multi> listen(CacheListenerOptions options, CacheEntryEventType... types) {
return Multi.createFrom().publisher(remoteCache.listen(options, types));
}
@Override
public Multi> process(Set keys, MutinyCacheEntryProcessor processor, CacheOptions options) {
return Multi.createFrom().publisher(remoteCache.process(keys, new MutinyToAsyncCacheEntryProcessor<>(processor), options));
}
@Override
public MutinyStreamingCache streaming() {
return new HotRodMutinyStreamingCache<>(hotrod, remoteCache);
}
}