io.quarkus.redis.runtime.datasource.ReactiveBloomCommandsImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-redis-client Show documentation
Show all versions of quarkus-redis-client Show documentation
Connect to Redis in either imperative or reactive style
package io.quarkus.redis.runtime.datasource;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import io.quarkus.redis.datasource.ReactiveRedisDataSource;
import io.quarkus.redis.datasource.bloom.BfInsertArgs;
import io.quarkus.redis.datasource.bloom.BfReserveArgs;
import io.quarkus.redis.datasource.bloom.ReactiveBloomCommands;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.redis.client.Response;
public class ReactiveBloomCommandsImpl extends AbstractBloomCommands
implements ReactiveBloomCommands {
private final ReactiveRedisDataSource reactive;
public ReactiveBloomCommandsImpl(ReactiveRedisDataSourceImpl redis, Type k, Type v) {
super(redis, k, v);
this.reactive = redis;
}
@Override
public ReactiveRedisDataSource getDataSource() {
return reactive;
}
@Override
public Uni bfadd(K key, V value) {
return _bfadd(key, value)
.map(Response::toBoolean);
}
@Override
public Uni bfexists(K key, V value) {
return _bfexists(key, value)
.map(Response::toBoolean);
}
@Override
public Uni> bfmadd(K key, V... values) {
return _bfmadd(key, values)
.map(ReactiveBloomCommandsImpl::decodeAsListOfBooleans);
}
static List decodeAsListOfBooleans(Response r) {
List results = new ArrayList<>();
if (r == null) {
return results;
}
for (Response nested : r) {
results.add(nested.toBoolean());
}
return results;
}
@Override
public Uni> bfmexists(K key, V... values) {
return _bfmexists(key, values)
.map(ReactiveBloomCommandsImpl::decodeAsListOfBooleans);
}
@Override
public Uni bfreserve(K key, double errorRate, long capacity) {
return bfreserve(key, errorRate, capacity, new BfReserveArgs());
}
@Override
public Uni bfreserve(K key, double errorRate, long capacity, BfReserveArgs args) {
return _bfreserve(key, errorRate, capacity, args)
.replaceWithVoid();
}
@Override
public Uni> bfinsert(K key, BfInsertArgs args, V... values) {
return _bfinsert(key, args, values)
.map(ReactiveBloomCommandsImpl::decodeAsListOfBooleans);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy