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.
io.lettuce.core.AbstractRedisReactiveCommands Maven / Gradle / Ivy
Go to download
Advanced and thread-safe Java Redis client for synchronous, asynchronous, and
reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs
and much more.
/*
* Copyright 2011-Present, Redis Ltd. and Contributors
* All rights reserved.
*
* Licensed under the MIT License.
*
* This file contains contributions from third-party contributors
* licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.lettuce.core;
import io.lettuce.core.GeoArgs.Unit;
import io.lettuce.core.api.StatefulConnection;
import io.lettuce.core.api.reactive.*;
import io.lettuce.core.cluster.api.reactive.RedisClusterReactiveCommands;
import io.lettuce.core.codec.Base16;
import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.internal.LettuceAssert;
import io.lettuce.core.json.JsonParser;
import io.lettuce.core.json.JsonPath;
import io.lettuce.core.json.JsonType;
import io.lettuce.core.json.JsonValue;
import io.lettuce.core.json.arguments.JsonGetArgs;
import io.lettuce.core.json.arguments.JsonMsetArgs;
import io.lettuce.core.json.arguments.JsonRangeArgs;
import io.lettuce.core.json.arguments.JsonSetArgs;
import io.lettuce.core.models.stream.ClaimedMessages;
import io.lettuce.core.models.stream.PendingMessage;
import io.lettuce.core.models.stream.PendingMessages;
import io.lettuce.core.output.CommandOutput;
import io.lettuce.core.output.KeyStreamingChannel;
import io.lettuce.core.output.KeyValueStreamingChannel;
import io.lettuce.core.output.ScoredValueStreamingChannel;
import io.lettuce.core.output.ValueStreamingChannel;
import io.lettuce.core.protocol.Command;
import io.lettuce.core.protocol.CommandArgs;
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.ProtocolKeyword;
import io.lettuce.core.protocol.RedisCommand;
import io.lettuce.core.protocol.TracedCommand;
import io.lettuce.core.resource.ClientResources;
import io.lettuce.core.tracing.TraceContext;
import io.lettuce.core.tracing.TraceContextProvider;
import io.lettuce.core.tracing.Tracing;
import io.netty.util.concurrent.EventExecutorGroup;
import io.netty.util.concurrent.ImmediateEventExecutor;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
import static io.lettuce.core.protocol.CommandType.EXEC;
import static io.lettuce.core.protocol.CommandType.GEORADIUSBYMEMBER_RO;
import static io.lettuce.core.protocol.CommandType.GEORADIUS_RO;
/**
* A reactive and thread-safe API for a Redis connection.
*
* @param Key type.
* @param Value type.
* @author Mark Paluch
* @author Nikolai Perevozchikov
* @author Tugdual Grall
* @author dengliming
* @author Andrey Shlykov
* @author Ali Takavci
* @author Tihomir Mateev
* @since 4.0
*/
public abstract class AbstractRedisReactiveCommands
implements RedisAclReactiveCommands, RedisHashReactiveCommands, RedisKeyReactiveCommands,
RedisStringReactiveCommands, RedisListReactiveCommands, RedisSetReactiveCommands,
RedisSortedSetReactiveCommands, RedisScriptingReactiveCommands, RedisServerReactiveCommands,
RedisHLLReactiveCommands, BaseRedisReactiveCommands, RedisTransactionalReactiveCommands,
RedisGeoReactiveCommands, RedisClusterReactiveCommands, RedisJsonReactiveCommands {
private final StatefulConnection connection;
private final RedisCommandBuilder commandBuilder;
private final RedisJsonCommandBuilder jsonCommandBuilder;
private final Mono parser;
private final ClientResources clientResources;
private final boolean tracingEnabled;
private volatile EventExecutorGroup scheduler;
/**
* Initialize a new instance.
*
* @param connection the connection to operate on.
* @param codec the codec for command encoding.
*/
public AbstractRedisReactiveCommands(StatefulConnection connection, RedisCodec codec, Mono parser) {
this.connection = connection;
this.parser = parser;
this.commandBuilder = new RedisCommandBuilder<>(codec);
this.jsonCommandBuilder = new RedisJsonCommandBuilder<>(codec, parser);
this.clientResources = connection.getResources();
this.tracingEnabled = clientResources.tracing().isEnabled();
}
private EventExecutorGroup getScheduler() {
EventExecutorGroup scheduler = this.scheduler;
if (scheduler != null) {
return scheduler;
}
EventExecutorGroup schedulerToUse = ImmediateEventExecutor.INSTANCE;
if (connection.getOptions().isPublishOnScheduler()) {
schedulerToUse = connection.getResources().eventExecutorGroup();
}
return this.scheduler = schedulerToUse;
}
@Override
public JsonParser getJsonParser() {
return parser.block();
}
@Override
public Mono> aclCat() {
return createMono(commandBuilder::aclCat);
}
@Override
public Mono> aclCat(AclCategory category) {
return createMono(() -> commandBuilder.aclCat(category));
}
@Override
public Mono aclDeluser(String... usernames) {
return createMono(() -> commandBuilder.aclDeluser(usernames));
}
@Override
public Mono aclDryRun(String username, String command, String... args) {
return createMono(() -> commandBuilder.aclDryRun(username, command, args));
}
@Override
public Mono aclDryRun(String username, RedisCommand command) {
return createMono(() -> commandBuilder.aclDryRun(username, command));
}
@Override
public Mono aclGenpass() {
return createMono(commandBuilder::aclGenpass);
}
@Override
public Mono aclGenpass(int bits) {
return createMono(() -> commandBuilder.aclGenpass(bits));
}
@Override
public Mono> aclGetuser(String username) {
return createMono(() -> commandBuilder.aclGetuser(username));
}
@Override
public Flux aclList() {
return createDissolvingFlux(commandBuilder::aclList);
}
@Override
public Mono aclLoad() {
return createMono(commandBuilder::aclLoad);
}
@Override
public Flux> aclLog() {
return createDissolvingFlux(commandBuilder::aclLog);
}
@Override
public Flux> aclLog(int count) {
return createDissolvingFlux(() -> commandBuilder.aclLog(count));
}
@Override
public Mono aclLogReset() {
return createMono(commandBuilder::aclLogReset);
}
@Override
public Mono aclSave() {
return createMono(commandBuilder::aclSave);
}
@Override
public Mono aclSetuser(String username, AclSetuserArgs args) {
return createMono(() -> commandBuilder.aclSetuser(username, args));
}
@Override
public Flux aclUsers() {
return createDissolvingFlux(commandBuilder::aclUsers);
}
@Override
public Mono aclWhoami() {
return createMono(commandBuilder::aclWhoami);
}
@Override
public Mono append(K key, V value) {
return createMono(() -> commandBuilder.append(key, value));
}
@Override
public Mono asking() {
return createMono(commandBuilder::asking);
}
@Override
public Mono auth(CharSequence password) {
return createMono(() -> commandBuilder.auth(password));
}
@Override
public Mono auth(String username, CharSequence password) {
return createMono(() -> commandBuilder.auth(username, password));
}
@Override
public Mono bgrewriteaof() {
return createMono(commandBuilder::bgrewriteaof);
}
@Override
public Mono bgsave() {
return createMono(commandBuilder::bgsave);
}
@Override
public Mono bitcount(K key) {
return createMono(() -> commandBuilder.bitcount(key));
}
@Override
public Mono bitcount(K key, long start, long end) {
return createMono(() -> commandBuilder.bitcount(key, start, end));
}
@Override
public Flux> bitfield(K key, BitFieldArgs args) {
return createDissolvingFlux(() -> commandBuilder.bitfieldValue(key, args));
}
@Override
public Mono bitopAnd(K destination, K... keys) {
return createMono(() -> commandBuilder.bitopAnd(destination, keys));
}
@Override
public Mono bitopNot(K destination, K source) {
return createMono(() -> commandBuilder.bitopNot(destination, source));
}
@Override
public Mono bitopOr(K destination, K... keys) {
return createMono(() -> commandBuilder.bitopOr(destination, keys));
}
@Override
public Mono bitopXor(K destination, K... keys) {
return createMono(() -> commandBuilder.bitopXor(destination, keys));
}
@Override
public Mono bitpos(K key, boolean state) {
return createMono(() -> commandBuilder.bitpos(key, state));
}
@Override
public Mono bitpos(K key, boolean state, long start) {
return createMono(() -> commandBuilder.bitpos(key, state, start));
}
@Override
public Mono bitpos(K key, boolean state, long start, long end) {
return createMono(() -> commandBuilder.bitpos(key, state, start, end));
}
@Override
public Mono blmove(K source, K destination, LMoveArgs args, long timeout) {
return createMono(() -> commandBuilder.blmove(source, destination, args, timeout));
}
@Override
public Mono blmove(K source, K destination, LMoveArgs args, double timeout) {
return createMono(() -> commandBuilder.blmove(source, destination, args, timeout));
}
@Override
public Mono>> blmpop(long timeout, LMPopArgs args, K... keys) {
return createMono(() -> commandBuilder.blmpop(timeout, args, keys));
}
@Override
public Mono>> blmpop(double timeout, LMPopArgs args, K... keys) {
return createMono(() -> commandBuilder.blmpop(timeout, args, keys));
}
@Override
public Mono> blpop(long timeout, K... keys) {
return createMono(() -> commandBuilder.blpop(timeout, keys));
}
@Override
public Mono> blpop(double timeout, K... keys) {
return createMono(() -> commandBuilder.blpop(timeout, keys));
}
@Override
public Mono> brpop(long timeout, K... keys) {
return createMono(() -> commandBuilder.brpop(timeout, keys));
}
@Override
public Mono> brpop(double timeout, K... keys) {
return createMono(() -> commandBuilder.brpop(timeout, keys));
}
@Override
public Mono brpoplpush(long timeout, K source, K destination) {
return createMono(() -> commandBuilder.brpoplpush(timeout, source, destination));
}
@Override
public Mono brpoplpush(double timeout, K source, K destination) {
return createMono(() -> commandBuilder.brpoplpush(timeout, source, destination));
}
@Override
public Mono clientCaching(boolean enabled) {
return createMono(() -> commandBuilder.clientCaching(enabled));
}
@Override
public Mono clientGetname() {
return createMono(commandBuilder::clientGetname);
}
@Override
public Mono clientGetredir() {
return createMono(commandBuilder::clientGetredir);
}
@Override
public Mono clientKill(String addr) {
return createMono(() -> commandBuilder.clientKill(addr));
}
@Override
public Mono clientKill(KillArgs killArgs) {
return createMono(() -> commandBuilder.clientKill(killArgs));
}
@Override
public Mono clientList() {
return createMono(commandBuilder::clientList);
}
@Override
public Mono clientList(ClientListArgs clientListArgs) {
return createMono(() -> commandBuilder.clientList(clientListArgs));
}
@Override
public Mono clientInfo() {
return createMono(commandBuilder::clientInfo);
}
@Override
public Mono clientNoEvict(boolean on) {
return createMono(() -> commandBuilder.clientNoEvict(on));
}
@Override
public Mono clientId() {
return createMono(commandBuilder::clientId);
}
@Override
public Mono clientPause(long timeout) {
return createMono(() -> commandBuilder.clientPause(timeout));
}
@Override
public Mono clientSetname(K name) {
return createMono(() -> commandBuilder.clientSetname(name));
}
@Override
public Mono clientSetinfo(String key, String value) {
return createMono(() -> commandBuilder.clientSetinfo(key, value));
}
@Override
public Mono clientTracking(TrackingArgs args) {
return createMono(() -> commandBuilder.clientTracking(args));
}
@Override
public Mono clientTrackinginfo() {
return createMono(commandBuilder::clientTrackinginfo);
}
@Override
public Mono clientUnblock(long id, UnblockType type) {
return createMono(() -> commandBuilder.clientUnblock(id, type));
}
public void close() {
connection.close();
}
@Override
public Mono clusterAddSlots(int... slots) {
return createMono(() -> commandBuilder.clusterAddslots(slots));
}
@Override
public Mono clusterAddSlotsRange(Range... ranges) {
return createMono(() -> commandBuilder.clusterAddSlotsRange(ranges));
}
@Override
public Mono clusterBumpepoch() {
return createMono(() -> commandBuilder.clusterBumpepoch());
}
@Override
public Mono clusterCountFailureReports(String nodeId) {
return createMono(() -> commandBuilder.clusterCountFailureReports(nodeId));
}
@Override
public Mono clusterCountKeysInSlot(int slot) {
return createMono(() -> commandBuilder.clusterCountKeysInSlot(slot));
}
@Override
public Mono clusterDelSlots(int... slots) {
return createMono(() -> commandBuilder.clusterDelslots(slots));
}
@Override
public Mono clusterDelSlotsRange(Range... ranges) {
return createMono(() -> commandBuilder.clusterDelSlotsRange(ranges));
}
@Override
public Mono clusterFailover(boolean force) {
return createMono(() -> commandBuilder.clusterFailover(force));
}
@Override
public Mono clusterFailover(boolean force, boolean takeOver) {
return createMono(() -> commandBuilder.clusterFailover(force, takeOver));
}
@Override
public Mono clusterFlushslots() {
return createMono(commandBuilder::clusterFlushslots);
}
@Override
public Mono clusterForget(String nodeId) {
return createMono(() -> commandBuilder.clusterForget(nodeId));
}
@Override
public Flux clusterGetKeysInSlot(int slot, int count) {
return createDissolvingFlux(() -> commandBuilder.clusterGetKeysInSlot(slot, count));
}
@Override
public Mono clusterInfo() {
return createMono(commandBuilder::clusterInfo);
}
@Override
public Mono clusterKeyslot(K key) {
return createMono(() -> commandBuilder.clusterKeyslot(key));
}
@Override
public Mono clusterMeet(String ip, int port) {
return createMono(() -> commandBuilder.clusterMeet(ip, port));
}
@Override
public Mono clusterMyId() {
return createMono(commandBuilder::clusterMyId);
}
@Override
public Mono clusterMyShardId() {
return createMono(commandBuilder::clusterMyShardId);
}
@Override
public Mono clusterNodes() {
return createMono(commandBuilder::clusterNodes);
}
@Override
public Mono clusterReplicate(String nodeId) {
return createMono(() -> commandBuilder.clusterReplicate(nodeId));
}
@Override
public Flux clusterReplicas(String nodeId) {
return createDissolvingFlux(() -> commandBuilder.clusterReplicas(nodeId));
}
@Override
public Mono clusterReset(boolean hard) {
return createMono(() -> commandBuilder.clusterReset(hard));
}
@Override
public Mono clusterSaveconfig() {
return createMono(() -> commandBuilder.clusterSaveconfig());
}
@Override
public Mono clusterSetConfigEpoch(long configEpoch) {
return createMono(() -> commandBuilder.clusterSetConfigEpoch(configEpoch));
}
@Override
public Mono clusterSetSlotImporting(int slot, String nodeId) {
return createMono(() -> commandBuilder.clusterSetSlotImporting(slot, nodeId));
}
@Override
public Mono clusterSetSlotMigrating(int slot, String nodeId) {
return createMono(() -> commandBuilder.clusterSetSlotMigrating(slot, nodeId));
}
@Override
public Mono clusterSetSlotNode(int slot, String nodeId) {
return createMono(() -> commandBuilder.clusterSetSlotNode(slot, nodeId));
}
@Override
public Mono clusterSetSlotStable(int slot) {
return createMono(() -> commandBuilder.clusterSetSlotStable(slot));
}
@Override
public Mono> clusterShards() {
return createMono(() -> commandBuilder.clusterShards());
}
@Override
public Flux clusterSlaves(String nodeId) {
return createDissolvingFlux(() -> commandBuilder.clusterSlaves(nodeId));
}
@Override
public Flux clusterSlots() {
return createDissolvingFlux(commandBuilder::clusterSlots);
}
@Override
public Flux command() {
return createDissolvingFlux(commandBuilder::command);
}
@Override
public Mono commandCount() {
return createMono(commandBuilder::commandCount);
}
@Override
public Flux commandInfo(String... commands) {
return createDissolvingFlux(() -> commandBuilder.commandInfo(commands));
}
@Override
public Flux commandInfo(CommandType... commands) {
String[] stringCommands = new String[commands.length];
for (int i = 0; i < commands.length; i++) {
stringCommands[i] = commands[i].name();
}
return commandInfo(stringCommands);
}
@Override
public Mono> configGet(String parameter) {
return createMono(() -> commandBuilder.configGet(parameter));
}
@Override
public Mono> configGet(String... parameters) {
return createMono(() -> commandBuilder.configGet(parameters));
}
@Override
public Mono configResetstat() {
return createMono(commandBuilder::configResetstat);
}
@Override
public Mono configRewrite() {
return createMono(commandBuilder::configRewrite);
}
@Override
public Mono configSet(String parameter, String value) {
return createMono(() -> commandBuilder.configSet(parameter, value));
}
@Override
public Mono configSet(Map kvs) {
return createMono(() -> commandBuilder.configSet(kvs));
}
@SuppressWarnings("unchecked")
public Flux createDissolvingFlux(Supplier> commandSupplier) {
return (Flux) createFlux(commandSupplier, true);
}
public Flux createFlux(Supplier> commandSupplier) {
return createFlux(commandSupplier, false);
}
private Flux createFlux(Supplier> commandSupplier, boolean dissolve) {
if (tracingEnabled) {
return withTraceContext().flatMapMany(it -> Flux
.from(new RedisPublisher<>(decorate(commandSupplier, it), connection, dissolve, getScheduler().next())));
}
return Flux.from(new RedisPublisher<>(commandSupplier, connection, dissolve, getScheduler().next()));
}
private Mono withTraceContext() {
return Tracing.getContext()
.switchIfEmpty(Mono.fromSupplier(() -> clientResources.tracing().initialTraceContextProvider()))
.flatMap(TraceContextProvider::getTraceContextLater).defaultIfEmpty(TraceContext.EMPTY);
}
protected Mono createMono(CommandType type, CommandOutput output, CommandArgs args) {
return createMono(() -> new Command<>(type, output, args));
}
public Mono createMono(Supplier> commandSupplier) {
if (tracingEnabled) {
return withTraceContext().flatMap(it -> Mono
.from(new RedisPublisher<>(decorate(commandSupplier, it), connection, false, getScheduler().next())));
}
return Mono.from(new RedisPublisher<>(commandSupplier, connection, false, getScheduler().next()));
}
private Supplier> decorate(Supplier> commandSupplier,
TraceContext traceContext) {
return () -> new TracedCommand<>(commandSupplier.get(), traceContext);
}
@Override
public Mono dbsize() {
return createMono(commandBuilder::dbsize);
}
@Override
public Mono debugCrashAndRecover(Long delay) {
return createMono(() -> (commandBuilder.debugCrashAndRecover(delay)));
}
@Override
public Mono debugHtstats(int db) {
return createMono(() -> commandBuilder.debugHtstats(db));
}
@Override
public Mono debugObject(K key) {
return createMono(() -> commandBuilder.debugObject(key));
}
@Override
public Mono debugOom() {
return createMono(commandBuilder::debugOom).then();
}
@Override
public Mono debugReload() {
return createMono(() -> (commandBuilder.debugReload()));
}
@Override
public Mono debugRestart(Long delay) {
return createMono(() -> (commandBuilder.debugRestart(delay)));
}
@Override
public Mono debugSdslen(K key) {
return createMono(() -> (commandBuilder.debugSdslen(key)));
}
@Override
public Mono debugSegfault() {
return createFlux(commandBuilder::debugSegfault).then();
}
@Override
public Mono decr(K key) {
return createMono(() -> commandBuilder.decr(key));
}
@Override
public Mono decrby(K key, long amount) {
return createMono(() -> commandBuilder.decrby(key, amount));
}
@Override
public Mono del(K... keys) {
return createMono(() -> commandBuilder.del(keys));
}
public Mono del(Iterable keys) {
return createMono(() -> commandBuilder.del(keys));
}
@Override
public String digest(String script) {
return digest(encodeScript(script));
}
@Override
public String digest(byte[] script) {
return Base16.digest(script);
}
@Override
public Mono discard() {
return createMono(commandBuilder::discard);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Flux dispatch(ProtocolKeyword type, CommandOutput output) {
LettuceAssert.notNull(type, "Command type must not be null");
LettuceAssert.notNull(output, "CommandOutput type must not be null");
return (Flux) createFlux(() -> new Command<>(type, output));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Flux dispatch(ProtocolKeyword type, CommandOutput output, CommandArgs args) {
LettuceAssert.notNull(type, "Command type must not be null");
LettuceAssert.notNull(output, "CommandOutput type must not be null");
LettuceAssert.notNull(args, "CommandArgs type must not be null");
return (Flux) createFlux(() -> new Command<>(type, output, args));
}
@Override
public Mono dump(K key) {
return createMono(() -> commandBuilder.dump(key));
}
@Override
public Mono echo(V msg) {
return createMono(() -> commandBuilder.echo(msg));
}
@Override
@SuppressWarnings("unchecked")
public Flux eval(String script, ScriptOutputType type, K... keys) {
return eval(encodeScript(script), type, keys);
}
@Override
@SuppressWarnings("unchecked")
public Flux eval(byte[] script, ScriptOutputType type, K... keys) {
return createFlux(() -> commandBuilder.eval(script, type, keys));
}
@Override
@SuppressWarnings("unchecked")
public Flux eval(String script, ScriptOutputType type, K[] keys, V... values) {
return eval(encodeScript(script), type, keys, values);
}
@Override
@SuppressWarnings("unchecked")
public Flux eval(byte[] script, ScriptOutputType type, K[] keys, V... values) {
return createFlux(() -> commandBuilder.eval(script, type, keys, values));
}
@Override
@SuppressWarnings("unchecked")
public Flux evalReadOnly(String script, ScriptOutputType type, K[] keys, V... values) {
return evalReadOnly(encodeScript(script), type, keys, values);
}
@Override
public Flux evalReadOnly(byte[] script, ScriptOutputType type, K[] keys, V... values) {
return createFlux(() -> commandBuilder.eval(script, type, true, keys, values));
}
@Override
@SuppressWarnings("unchecked")
public Flux evalsha(String digest, ScriptOutputType type, K... keys) {
return createFlux(() -> commandBuilder.evalsha(digest, type, keys));
}
@Override
@SuppressWarnings("unchecked")
public Flux evalsha(String digest, ScriptOutputType type, K[] keys, V... values) {
return createFlux(() -> commandBuilder.evalsha(digest, type, keys, values));
}
@Override
public Flux evalshaReadOnly(String digest, ScriptOutputType type, K[] keys, V... values) {
return createFlux(() -> commandBuilder.evalsha(digest, type, true, keys, values));
}
@Override
public Mono exec() {
return createMono(EXEC, null, null);
}
public Mono exists(K key) {
return createMono(() -> commandBuilder.exists(key));
}
@Override
public Mono exists(K... keys) {
return createMono(() -> commandBuilder.exists(keys));
}
public Mono exists(Iterable keys) {
return createMono(() -> commandBuilder.exists(keys));
}
@Override
public Mono expire(K key, long seconds) {
return expire(key, seconds, null);
}
@Override
public Mono expire(K key, long seconds, ExpireArgs expireArgs) {
return createMono(() -> commandBuilder.expire(key, seconds, expireArgs));
}
@Override
public Mono expire(K key, Duration seconds) {
return expire(key, seconds, null);
}
@Override
public Mono expire(K key, Duration seconds, ExpireArgs expireArgs) {
LettuceAssert.notNull(seconds, "Timeout must not be null");
return expire(key, seconds.toMillis() / 1000, expireArgs);
}
@Override
public Flux hexpire(K key, long seconds, K... fields) {
return hexpire(key, seconds, null, fields);
}
@Override
public Flux hexpire(K key, long seconds, ExpireArgs expireArgs, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hexpire(key, seconds, expireArgs, fields));
}
@Override
public Flux hexpire(K key, Duration seconds, K... fields) {
return hexpire(key, seconds, null, fields);
}
@Override
public Flux hexpire(K key, Duration seconds, ExpireArgs expireArgs, K... fields) {
LettuceAssert.notNull(seconds, "Timeout must not be null");
return hexpire(key, seconds.toMillis() / 1000, expireArgs, fields);
}
@Override
public Mono expireat(K key, long timestamp) {
return expireat(key, timestamp, null);
}
@Override
public Mono expireat(K key, long timestamp, ExpireArgs expireArgs) {
return createMono(() -> commandBuilder.expireat(key, timestamp, expireArgs));
}
@Override
public Mono expireat(K key, Date timestamp) {
return expireat(key, timestamp, null);
}
@Override
public Mono expireat(K key, Date timestamp, ExpireArgs expireArgs) {
LettuceAssert.notNull(timestamp, "Timestamp must not be null");
return expireat(key, timestamp.getTime() / 1000, expireArgs);
}
@Override
public Mono expireat(K key, Instant timestamp) {
return expireat(key, timestamp, null);
}
@Override
public Mono expireat(K key, Instant timestamp, ExpireArgs expireArgs) {
LettuceAssert.notNull(timestamp, "Timestamp must not be null");
return expireat(key, timestamp.toEpochMilli() / 1000, expireArgs);
}
@Override
public Flux hexpireat(K key, long timestamp, K... fields) {
return hexpireat(key, timestamp, null, fields);
}
@Override
public Flux hexpireat(K key, long timestamp, ExpireArgs expireArgs, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hexpireat(key, timestamp, expireArgs, fields));
}
@Override
public Flux hexpireat(K key, Date timestamp, K... fields) {
return hexpireat(key, timestamp, null, fields);
}
@Override
public Flux hexpireat(K key, Date timestamp, ExpireArgs expireArgs, K... fields) {
LettuceAssert.notNull(timestamp, "Timestamp must not be null");
return hexpireat(key, timestamp.getTime() / 1000, expireArgs, fields);
}
@Override
public Flux hexpireat(K key, Instant timestamp, K... fields) {
return hexpireat(key, timestamp, null, fields);
}
@Override
public Flux hexpireat(K key, Instant timestamp, ExpireArgs expireArgs, K... fields) {
LettuceAssert.notNull(timestamp, "Timestamp must not be null");
return hexpireat(key, timestamp.toEpochMilli() / 1000, expireArgs, fields);
}
@Override
public Mono expiretime(K key) {
return createMono(() -> commandBuilder.expiretime(key));
}
@Override
public Flux hexpiretime(K key, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hexpiretime(key, fields));
}
@Override
public Flux httl(K key, K... fields) {
return createDissolvingFlux(() -> commandBuilder.httl(key, fields));
}
@Override
public Flux hpexpire(K key, long milliseconds, K... fields) {
return hpexpire(key, milliseconds, null, fields);
}
@Override
public Flux hpexpire(K key, long milliseconds, ExpireArgs expireArgs, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hpexpire(key, milliseconds, expireArgs, fields));
}
@Override
public Flux hpexpire(K key, Duration milliseconds, K... fields) {
return hpexpire(key, milliseconds, null, fields);
}
@Override
public Flux hpexpire(K key, Duration milliseconds, ExpireArgs expireArgs, K... fields) {
LettuceAssert.notNull(milliseconds, "Timeout must not be null");
return hpexpire(key, milliseconds.toMillis(), expireArgs, fields);
}
@Override
public Flux hpexpireat(K key, Date timestamp, K... fields) {
return hpexpireat(key, timestamp, null, fields);
}
@Override
public Flux hpexpireat(K key, Date timestamp, ExpireArgs expireArgs, K... fields) {
LettuceAssert.notNull(timestamp, "Timestamp must not be null");
return hpexpireat(key, timestamp.getTime(), expireArgs, fields);
}
@Override
public Flux hpexpireat(K key, Instant timestamp, K... fields) {
return hpexpireat(key, timestamp, null, fields);
}
@Override
public Flux hpexpireat(K key, Instant timestamp, ExpireArgs expireArgs, K... fields) {
LettuceAssert.notNull(timestamp, "Timestamp must not be null");
return hpexpireat(key, timestamp.toEpochMilli(), expireArgs, fields);
}
@Override
public Flux hpexpireat(K key, long timestamp, K... fields) {
return hpexpireat(key, timestamp, null, fields);
}
@Override
public Flux hpexpireat(K key, long timestamp, ExpireArgs expireArgs, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hpexpireat(key, timestamp, expireArgs, fields));
}
@Override
public Flux hpexpiretime(K key, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hpexpiretime(key, fields));
}
@Override
public Flux hpttl(K key, K... fields) {
return createDissolvingFlux(() -> commandBuilder.hpttl(key, fields));
}
@Override
public Flux fcall(String function, ScriptOutputType type, K... keys) {
return createFlux(() -> commandBuilder.fcall(function, type, false, keys));
}
@Override
public Flux fcall(String function, ScriptOutputType type, K[] keys, V... values) {
return createFlux(() -> commandBuilder.fcall(function, type, false, keys, values));
}
@Override
public Flux fcallReadOnly(String function, ScriptOutputType type, K... keys) {
return createFlux(() -> commandBuilder.fcall(function, type, true, keys));
}
@Override
public Flux fcallReadOnly(String function, ScriptOutputType type, K[] keys, V... values) {
return createFlux(() -> commandBuilder.fcall(function, type, true, keys, values));
}
@Override
public Mono functionLoad(String functionCode) {
return functionLoad(functionCode, false);
}
@Override
public Mono functionLoad(String functionCode, boolean replace) {
return createMono(() -> commandBuilder.functionLoad(encodeScript(functionCode), replace));
}
@Override
public Mono functionDump() {
return createMono(commandBuilder::functionDump);
}
@Override
public Mono functionRestore(byte[] dump) {
return createMono(() -> commandBuilder.functionRestore(dump, null));
}
@Override
public Mono functionRestore(byte[] dump, FunctionRestoreMode mode) {
return createMono(() -> commandBuilder.functionRestore(dump, mode));
}
@Override
public Mono functionFlush(FlushMode flushMode) {
return createMono(() -> commandBuilder.functionFlush(flushMode));
}
@Override
public Mono functionKill() {
return createMono(commandBuilder::functionKill);
}
@Override
public Flux> functionList() {
return createDissolvingFlux(() -> commandBuilder.functionList(null));
}
@Override
public Flux> functionList(String libraryName) {
return createDissolvingFlux(() -> commandBuilder.functionList(libraryName));
}
@Override
public void flushCommands() {
connection.flushCommands();
}
@Override
public Mono flushall() {
return createMono(commandBuilder::flushall);
}
@Override
public Mono flushall(FlushMode flushMode) {
return createMono(() -> commandBuilder.flushall(flushMode));
}
@Override
public Mono