io.quarkus.redis.runtime.datasource.AbstractCuckooCommands 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 static io.smallrye.mutiny.helpers.ParameterValidation.doesNotContainNull;
import static io.smallrye.mutiny.helpers.ParameterValidation.nonNull;
import java.lang.reflect.Type;
import io.quarkus.redis.datasource.cuckoo.CfInsertArgs;
import io.quarkus.redis.datasource.cuckoo.CfReserveArgs;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.redis.client.Command;
import io.vertx.mutiny.redis.client.Response;
public class AbstractCuckooCommands extends AbstractRedisCommands {
AbstractCuckooCommands(RedisCommandExecutor redis, Type k, Type v) {
super(redis, new Marshaller(k, v));
}
Uni _cfadd(K key, V value) {
// Validation
nonNull(key, "key");
nonNull(value, "value");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_ADD)
.put(marshaller.encode(key))
.put(marshaller.encode(value));
return execute(cmd);
}
Uni _cfaddnx(K key, V value) {
// Validation
nonNull(key, "key");
nonNull(value, "value");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_ADDNX)
.put(marshaller.encode(key))
.put(marshaller.encode(value));
return execute(cmd);
}
Uni _cfcount(K key, V value) {
// Validation
nonNull(key, "key");
nonNull(value, "value");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_COUNT)
.put(marshaller.encode(key))
.put(marshaller.encode(value));
return execute(cmd);
}
Uni _cfdel(K key, V value) {
// Validation
nonNull(key, "key");
nonNull(value, "value");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_DEL)
.put(marshaller.encode(key))
.put(marshaller.encode(value));
return execute(cmd);
}
Uni _cfexists(K key, V value) {
// Validation
nonNull(key, "key");
nonNull(value, "value");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_EXISTS)
.put(marshaller.encode(key))
.put(marshaller.encode(value));
return execute(cmd);
}
Uni _cfinsert(K key, V... values) {
// Validation
nonNull(key, "key");
doesNotContainNull(values, "values");
if (values.length == 0) {
throw new IllegalArgumentException("`values` must contain at least one item");
}
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_INSERT)
.put(marshaller.encode(key));
for (V value : values) {
cmd.put(marshaller.encode(value));
}
return execute(cmd);
}
Uni _cfinsert(K key, CfInsertArgs args, V... values) {
// Validation
nonNull(key, "key");
nonNull(args, "args");
doesNotContainNull(values, "values");
if (values.length == 0) {
throw new IllegalArgumentException("`values` must contain at least one item");
}
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_INSERT)
.put(marshaller.encode(key))
.putArgs(args)
.put("ITEMS");
for (V value : values) {
cmd.put(marshaller.encode(value));
}
return execute(cmd);
}
Uni _cfinsertnx(K key, V... values) {
// Validation
nonNull(key, "key");
doesNotContainNull(values, "values");
if (values.length == 0) {
throw new IllegalArgumentException("`values` must contain at least one item");
}
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_INSERTNX)
.put(marshaller.encode(key))
.put("ITEMS");
for (V value : values) {
cmd.put(marshaller.encode(value));
}
return execute(cmd);
}
Uni _cfinsertnx(K key, CfInsertArgs args, V... values) {
// Validation
nonNull(key, "key");
doesNotContainNull(values, "values");
nonNull(args, "args");
if (values.length == 0) {
throw new IllegalArgumentException("`values` must contain at least one item");
}
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_INSERTNX)
.put(marshaller.encode(key))
.putArgs(args)
.put("ITEMS");
for (V value : values) {
cmd.put(marshaller.encode(value));
}
return execute(cmd);
}
Uni _cfmexists(K key, V... values) {
// Validation
nonNull(key, "key");
doesNotContainNull(values, "values");
if (values.length == 0) {
throw new IllegalArgumentException("`values` must contain at least one item");
}
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_MEXISTS)
.put(marshaller.encode(key));
for (V value : values) {
cmd.put(marshaller.encode(value));
}
return execute(cmd);
}
Uni _cfreserve(K key, long capacity) {
// Validation
nonNull(key, "key");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_RESERVE)
.put(marshaller.encode(key))
.put(capacity);
return execute(cmd);
}
Uni _cfreserve(K key, long capacity, CfReserveArgs args) {
// Validation
nonNull(key, "key");
nonNull(args, "args");
// Create command
RedisCommand cmd = RedisCommand.of(Command.CF_RESERVE)
.put(marshaller.encode(key))
.put(capacity)
.putArgs(args);
return execute(cmd);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy