From 986bb09861712313ad5ef8859f13a8d293c7627f Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 26 Sep 2017 10:26:01 +0200 Subject: [PATCH] Polishing #604 Remove public keywords in RedisCommandBuilder. Replace explicit type arguments with diamond syntax. Order by method name in AbstractRedisAsyncCommands, RedisCommandBuilder, and AbstractRedisReactiveCommands. --- .../redis/AbstractRedisAsyncCommands.java | 1352 +++---- .../redis/AbstractRedisReactiveCommands.java | 1423 ++++---- .../redis/RedisCommandBuilder.java | 3094 ++++++++--------- 3 files changed, 2934 insertions(+), 2935 deletions(-) diff --git a/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java b/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java index f58615ba1b..0c822ede22 100644 --- a/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java +++ b/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java @@ -39,21 +39,22 @@ * @param Value type. * @author Will Glozer */ -public abstract class AbstractRedisAsyncCommands - implements RedisHashesAsyncConnection, RedisKeysAsyncConnection, RedisStringsAsyncConnection, - RedisListsAsyncConnection, RedisSetsAsyncConnection, RedisSortedSetsAsyncConnection, - RedisScriptingAsyncConnection, RedisServerAsyncConnection, RedisHLLAsyncConnection, - BaseRedisAsyncConnection, RedisClusterAsyncConnection, RedisGeoAsyncConnection, +public abstract class AbstractRedisAsyncCommands implements RedisHashesAsyncConnection, + RedisKeysAsyncConnection, RedisStringsAsyncConnection, RedisListsAsyncConnection, + RedisSetsAsyncConnection, RedisSortedSetsAsyncConnection, RedisScriptingAsyncConnection, + RedisServerAsyncConnection, RedisHLLAsyncConnection, BaseRedisAsyncConnection, + RedisClusterAsyncConnection, RedisGeoAsyncConnection, + + RedisHashAsyncCommands, RedisKeyAsyncCommands, RedisStringAsyncCommands, + RedisListAsyncCommands, RedisSetAsyncCommands, RedisSortedSetAsyncCommands, + RedisScriptingAsyncCommands, RedisServerAsyncCommands, RedisHLLAsyncCommands, + BaseRedisAsyncCommands, RedisTransactionalAsyncCommands, RedisGeoAsyncCommands, + RedisClusterAsyncCommands { - RedisHashAsyncCommands, RedisKeyAsyncCommands, RedisStringAsyncCommands, RedisListAsyncCommands, - RedisSetAsyncCommands, RedisSortedSetAsyncCommands, RedisScriptingAsyncCommands, - RedisServerAsyncCommands, RedisHLLAsyncCommands, BaseRedisAsyncCommands, - RedisTransactionalAsyncCommands, RedisGeoAsyncCommands, RedisClusterAsyncCommands { - - protected MultiOutput multi; - protected RedisCommandBuilder commandBuilder; - protected RedisCodec codec; protected StatefulConnection connection; + protected RedisCodec codec; + protected RedisCommandBuilder commandBuilder; + protected MultiOutput multi; /** * Initialize a new instance. @@ -72,6 +73,11 @@ public RedisFuture append(K key, V value) { return dispatch(commandBuilder.append(key, value)); } + @Override + public RedisFuture asking() { + return dispatch(commandBuilder.asking()); + } + @Override public String auth(String password) { @@ -109,16 +115,6 @@ public RedisFuture> bitfield(K key, BitFieldArgs bitFieldArgs) { return dispatch(commandBuilder.bitfield(key, bitFieldArgs)); } - @Override - public RedisFuture bitpos(K key, boolean state) { - return dispatch(commandBuilder.bitpos(key, state)); - } - - @Override - public RedisFuture bitpos(K key, boolean state, long start, long end) { - return dispatch(commandBuilder.bitpos(key, state, start, end)); - } - @Override public RedisFuture bitopAnd(K destination, K... keys) { return dispatch(commandBuilder.bitopAnd(destination, keys)); @@ -139,6 +135,16 @@ public RedisFuture bitopXor(K destination, K... keys) { return dispatch(commandBuilder.bitopXor(destination, keys)); } + @Override + public RedisFuture bitpos(K key, boolean state) { + return dispatch(commandBuilder.bitpos(key, state)); + } + + @Override + public RedisFuture bitpos(K key, boolean state, long start, long end) { + return dispatch(commandBuilder.bitpos(key, state, start, end)); + } + @Override public RedisFuture> blpop(long timeout, K... keys) { return dispatch(commandBuilder.blpop(timeout, keys)); @@ -159,11 +165,6 @@ public RedisFuture clientGetname() { return dispatch(commandBuilder.clientGetname()); } - @Override - public RedisFuture clientSetname(K name) { - return dispatch(commandBuilder.clientSetname(name)); - } - @Override public RedisFuture clientKill(String addr) { return dispatch(commandBuilder.clientKill(addr)); @@ -174,14 +175,144 @@ public RedisFuture clientKill(KillArgs killArgs) { return dispatch(commandBuilder.clientKill(killArgs)); } + @Override + public RedisFuture clientList() { + return dispatch(commandBuilder.clientList()); + } + @Override public RedisFuture clientPause(long timeout) { return dispatch(commandBuilder.clientPause(timeout)); } @Override - public RedisFuture clientList() { - return dispatch(commandBuilder.clientList()); + public RedisFuture clientSetname(K name) { + return dispatch(commandBuilder.clientSetname(name)); + } + + @Override + public void close() { + connection.close(); + } + + @Override + public RedisFuture clusterAddSlots(int... slots) { + return dispatch(commandBuilder.clusterAddslots(slots)); + } + + @Override + public RedisFuture clusterBumpepoch() { + return dispatch(commandBuilder.clusterBumpepoch()); + } + + @Override + public RedisFuture clusterCountFailureReports(String nodeId) { + return dispatch(commandBuilder.clusterCountFailureReports(nodeId)); + } + + @Override + public RedisFuture clusterCountKeysInSlot(int slot) { + return dispatch(commandBuilder.clusterCountKeysInSlot(slot)); + } + + @Override + public RedisFuture clusterDelSlots(int... slots) { + return dispatch(commandBuilder.clusterDelslots(slots)); + } + + @Override + public RedisFuture clusterFailover(boolean force) { + return dispatch(commandBuilder.clusterFailover(force)); + } + + @Override + public RedisFuture clusterFlushslots() { + return dispatch(commandBuilder.clusterFlushslots()); + } + + @Override + public RedisFuture clusterForget(String nodeId) { + return dispatch(commandBuilder.clusterForget(nodeId)); + } + + @Override + public RedisFuture> clusterGetKeysInSlot(int slot, int count) { + return dispatch(commandBuilder.clusterGetKeysInSlot(slot, count)); + } + + @Override + public RedisFuture clusterInfo() { + return dispatch(commandBuilder.clusterInfo()); + } + + @Override + public RedisFuture clusterKeyslot(K key) { + return dispatch(commandBuilder.clusterKeyslot(key)); + } + + @Override + public RedisFuture clusterMeet(String ip, int port) { + return dispatch(commandBuilder.clusterMeet(ip, port)); + } + + @Override + public RedisFuture clusterMyId() { + return dispatch(commandBuilder.clusterMyId()); + } + + @Override + public RedisFuture clusterNodes() { + return dispatch(commandBuilder.clusterNodes()); + } + + @Override + public RedisFuture clusterReplicate(String nodeId) { + return dispatch(commandBuilder.clusterReplicate(nodeId)); + } + + @Override + public RedisFuture clusterReset(boolean hard) { + return dispatch(commandBuilder.clusterReset(hard)); + } + + @Override + public RedisFuture clusterSaveconfig() { + return dispatch(commandBuilder.clusterSaveconfig()); + } + + @Override + public RedisFuture clusterSetConfigEpoch(long configEpoch) { + return dispatch(commandBuilder.clusterSetConfigEpoch(configEpoch)); + } + + @Override + public RedisFuture clusterSetSlotImporting(int slot, String nodeId) { + return dispatch(commandBuilder.clusterSetSlotImporting(slot, nodeId)); + } + + @Override + public RedisFuture clusterSetSlotMigrating(int slot, String nodeId) { + return dispatch(commandBuilder.clusterSetSlotMigrating(slot, nodeId)); + } + + @Override + public RedisFuture clusterSetSlotNode(int slot, String nodeId) { + return dispatch(commandBuilder.clusterSetSlotNode(slot, nodeId)); + } + + @Override + public RedisFuture clusterSetSlotStable(int slot) { + return dispatch(commandBuilder.clusterSetSlotStable(slot)); + } + + @Override + public RedisFuture> clusterSlaves(String nodeId) { + return dispatch(commandBuilder.clusterSlaves(nodeId)); + } + + @Override + public RedisFuture> clusterSlots() { + return dispatch(commandBuilder.clusterSlots()); } @Override @@ -189,6 +320,11 @@ public RedisFuture> command() { return dispatch(commandBuilder.command()); } + @Override + public RedisFuture commandCount() { + return dispatch(commandBuilder.commandCount()); + } + @Override public RedisFuture> commandInfo(String... commands) { return dispatch(commandBuilder.commandInfo(commands)); @@ -204,11 +340,6 @@ public RedisFuture> commandInfo(CommandType... commands) { return commandInfo(stringCommands); } - @Override - public RedisFuture commandCount() { - return dispatch(commandBuilder.commandCount()); - } - @Override public RedisFuture> configGet(String parameter) { return dispatch(commandBuilder.configGet(parameter)); @@ -220,13 +351,13 @@ public RedisFuture configResetstat() { } @Override - public RedisFuture configSet(String parameter, String value) { - return dispatch(commandBuilder.configSet(parameter, value)); + public RedisFuture configRewrite() { + return dispatch(commandBuilder.configRewrite()); } @Override - public RedisFuture configRewrite() { - return dispatch(commandBuilder.configRewrite()); + public RedisFuture configSet(String parameter, String value) { + return dispatch(commandBuilder.configSet(parameter, value)); } @Override @@ -294,12 +425,8 @@ public RedisFuture del(Iterable keys) { } @Override - public RedisFuture unlink(K... keys) { - return dispatch(commandBuilder.unlink(keys)); - } - - public RedisFuture unlink(Iterable keys) { - return dispatch(commandBuilder.unlink(keys)); + public String digest(V script) { + return LettuceStrings.digest(codec.encodeValue(script)); } @Override @@ -307,6 +434,42 @@ public RedisFuture discard() { return dispatch(commandBuilder.discard()); } + @Override + public RedisFuture dispatch(ProtocolKeyword type, CommandOutput output) { + + LettuceAssert.notNull(type, "Command type must not be null"); + LettuceAssert.notNull(output, "CommandOutput type must not be null"); + + return dispatch(new AsyncCommand<>(new Command<>(type, output))); + } + + @Override + public RedisFuture 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 dispatch(new AsyncCommand<>(new Command<>(type, output, args))); + } + + protected RedisFuture dispatch(CommandType type, CommandOutput output) { + return dispatch(type, output, null); + } + + protected RedisFuture dispatch(CommandType type, CommandOutput output, CommandArgs args) { + return dispatch(new AsyncCommand<>(new Command<>(type, output, args))); + } + + public AsyncCommand dispatch(RedisCommand cmd) { + AsyncCommand asyncCommand = new AsyncCommand<>(cmd); + RedisCommand dispatched = connection.dispatch(asyncCommand); + if (dispatched instanceof AsyncCommand) { + return (AsyncCommand) dispatched; + } + return asyncCommand; + } + @Override public RedisFuture dump(K key) { return dispatch(commandBuilder.dump(key)); @@ -341,6 +504,11 @@ public RedisFuture evalsha(String digest, ScriptOutputType type, K[] keys return (RedisFuture) dispatch(commandBuilder.evalsha(digest, type, keys, values)); } + @Override + public RedisFuture> exec() { + return dispatch(EXEC, null); + } + @Override public RedisFuture exists(K key) { return dispatch(commandBuilder.exists(key)); @@ -371,8 +539,8 @@ public RedisFuture expireat(K key, long timestamp) { } @Override - public RedisFuture> exec() { - return dispatch(EXEC, null); + public void flushCommands() { + connection.flushCommands(); } @Override @@ -396,23 +564,104 @@ public RedisFuture flushdbAsync() { } @Override - public RedisFuture get(K key) { - return dispatch(commandBuilder.get(key)); + public RedisFuture geoadd(K key, double longitude, double latitude, V member) { + return dispatch(commandBuilder.geoadd(key, longitude, latitude, member)); } @Override - public RedisFuture getbit(K key, long offset) { - return dispatch(commandBuilder.getbit(key, offset)); + public RedisFuture geoadd(K key, Object... lngLatMember) { + return dispatch(commandBuilder.geoadd(key, lngLatMember)); } @Override - public RedisFuture getrange(K key, long start, long end) { - return dispatch(commandBuilder.getrange(key, start, end)); + public RedisFuture geodist(K key, V from, V to, GeoArgs.Unit unit) { + return dispatch(commandBuilder.geodist(key, from, to, unit)); } @Override - public RedisFuture getset(K key, V value) { - return dispatch(commandBuilder.getset(key, value)); + public RedisFuture> geohash(K key, V... members) { + return dispatch(commandBuilder.geohash(key, members)); + } + + @Override + public RedisFuture> geopos(K key, V... members) { + return dispatch(commandBuilder.geopos(key, members)); + } + + @Override + public RedisFuture> georadius(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { + return dispatch(commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, unit.name())); + } + + @Override + public RedisFuture>> georadius(K key, double longitude, double latitude, double distance, + GeoArgs.Unit unit, GeoArgs geoArgs) { + return dispatch(commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, unit.name(), geoArgs)); + } + + @Override + public RedisFuture georadius(K key, double longitude, double latitude, double distance, Unit unit, + GeoRadiusStoreArgs geoRadiusStoreArgs) { + return dispatch(commandBuilder.georadius(key, longitude, latitude, distance, unit.name(), geoRadiusStoreArgs)); + } + + protected RedisFuture> georadius_ro(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { + return dispatch(commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, unit.name())); + } + + protected RedisFuture>> georadius_ro(K key, double longitude, double latitude, double distance, + GeoArgs.Unit unit, GeoArgs geoArgs) { + return dispatch(commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, unit.name(), geoArgs)); + } + + @Override + public RedisFuture> georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit) { + return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, unit.name())); + } + + @Override + public RedisFuture>> georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit, + GeoArgs geoArgs) { + return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, unit.name(), geoArgs)); + } + + @Override + public RedisFuture georadiusbymember(K key, V member, double distance, Unit unit, + GeoRadiusStoreArgs geoRadiusStoreArgs) { + return dispatch(commandBuilder.georadiusbymember(key, member, distance, unit.name(), geoRadiusStoreArgs)); + } + + protected RedisFuture> georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit) { + return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, unit.name())); + } + + protected RedisFuture>> georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit, + GeoArgs geoArgs) { + return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, unit.name(), geoArgs)); + } + + @Override + public RedisFuture get(K key) { + return dispatch(commandBuilder.get(key)); + } + + public StatefulConnection getConnection() { + return connection; + } + + @Override + public RedisFuture getbit(K key, long offset) { + return dispatch(commandBuilder.getbit(key, offset)); + } + + @Override + public RedisFuture getrange(K key, long start, long end) { + return dispatch(commandBuilder.getrange(key, start, end)); + } + + @Override + public RedisFuture getset(K key, V value) { + return dispatch(commandBuilder.getset(key, value)); } @Override @@ -431,23 +680,23 @@ public RedisFuture hget(K key, K field) { } @Override - public RedisFuture hincrby(K key, K field, long amount) { - return dispatch(commandBuilder.hincrby(key, field, amount)); + public RedisFuture> hgetall(K key) { + return dispatch(commandBuilder.hgetall(key)); } @Override - public RedisFuture hincrbyfloat(K key, K field, double amount) { - return dispatch(commandBuilder.hincrbyfloat(key, field, amount)); + public RedisFuture hgetall(KeyValueStreamingChannel channel, K key) { + return dispatch(commandBuilder.hgetall(channel, key)); } @Override - public RedisFuture> hgetall(K key) { - return dispatch(commandBuilder.hgetall(key)); + public RedisFuture hincrby(K key, K field, long amount) { + return dispatch(commandBuilder.hincrby(key, field, amount)); } @Override - public RedisFuture hgetall(KeyValueStreamingChannel channel, K key) { - return dispatch(commandBuilder.hgetall(channel, key)); + public RedisFuture hincrbyfloat(K key, K field, double amount) { + return dispatch(commandBuilder.hincrbyfloat(key, field, amount)); } @Override @@ -465,11 +714,6 @@ public RedisFuture hlen(K key) { return dispatch(commandBuilder.hlen(key)); } - @Override - public RedisFuture hstrlen(K key, K field) { - return dispatch(commandBuilder.hstrlen(key, field)); - } - @Override public RedisFuture> hmget(K key, K... fields) { return dispatch(commandBuilder.hmget(key, fields)); @@ -485,6 +729,47 @@ public RedisFuture hmset(K key, Map map) { return dispatch(commandBuilder.hmset(key, map)); } + @Override + public RedisFuture> hscan(K key) { + return dispatch(commandBuilder.hscan(key)); + } + + @Override + public RedisFuture> hscan(K key, ScanArgs scanArgs) { + return dispatch(commandBuilder.hscan(key, scanArgs)); + } + + @Override + public RedisFuture> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { + return dispatch(commandBuilder.hscan(key, scanCursor, scanArgs)); + } + + @Override + public RedisFuture> hscan(K key, ScanCursor scanCursor) { + return dispatch(commandBuilder.hscan(key, scanCursor)); + } + + @Override + public RedisFuture hscan(KeyValueStreamingChannel channel, K key) { + return dispatch(commandBuilder.hscanStreaming(channel, key)); + } + + @Override + public RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs) { + return dispatch(commandBuilder.hscanStreaming(channel, key, scanArgs)); + } + + @Override + public RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, + ScanArgs scanArgs) { + return dispatch(commandBuilder.hscanStreaming(channel, key, scanCursor, scanArgs)); + } + + @Override + public RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor) { + return dispatch(commandBuilder.hscanStreaming(channel, key, scanCursor)); + } + @Override public RedisFuture hset(K key, K field, V value) { return dispatch(commandBuilder.hset(key, field, value)); @@ -495,6 +780,11 @@ public RedisFuture hsetnx(K key, K field, V value) { return dispatch(commandBuilder.hsetnx(key, field, value)); } + @Override + public RedisFuture hstrlen(K key, K field) { + return dispatch(commandBuilder.hstrlen(key, field)); + } + @Override public RedisFuture> hvals(K key) { return dispatch(commandBuilder.hvals(key)); @@ -530,6 +820,11 @@ public RedisFuture info(String section) { return dispatch(commandBuilder.info(section)); } + @Override + public boolean isOpen() { + return connection.isOpen(); + } + @Override public RedisFuture> keys(K pattern) { return dispatch(commandBuilder.keys(pattern)); @@ -605,16 +900,6 @@ public RedisFuture ltrim(K key, long start, long stop) { return dispatch(commandBuilder.ltrim(key, start, stop)); } - @Override - public RedisFuture migrate(String host, int port, K key, int db, long timeout) { - return dispatch(commandBuilder.migrate(host, port, key, db, timeout)); - } - - @Override - public RedisFuture migrate(String host, int port, int db, long timeout, MigrateArgs migrateArgs) { - return dispatch(commandBuilder.migrate(host, port, db, timeout, migrateArgs)); - } - @Override public RedisFuture> mget(K... keys) { return dispatch(commandBuilder.mget(keys)); @@ -634,13 +919,18 @@ public RedisFuture mget(ValueStreamingChannel channel, Iterable keys } @Override - public RedisFuture move(K key, int db) { - return dispatch(commandBuilder.move(key, db)); + public RedisFuture migrate(String host, int port, K key, int db, long timeout) { + return dispatch(commandBuilder.migrate(host, port, key, db, timeout)); } @Override - public RedisFuture multi() { - return dispatch(commandBuilder.multi()); + public RedisFuture migrate(String host, int port, int db, long timeout, MigrateArgs migrateArgs) { + return dispatch(commandBuilder.migrate(host, port, db, timeout, migrateArgs)); + } + + @Override + public RedisFuture move(K key, int db) { + return dispatch(commandBuilder.move(key, db)); } @Override @@ -653,6 +943,11 @@ public RedisFuture msetnx(Map map) { return dispatch(commandBuilder.msetnx(map)); } + @Override + public RedisFuture multi() { + return dispatch(commandBuilder.multi()); + } + @Override public RedisFuture objectEncoding(K key) { return dispatch(commandBuilder.objectEncoding(key)); @@ -689,20 +984,43 @@ public RedisFuture pexpireat(K key, long timestamp) { } @Override - public RedisFuture ping() { - return dispatch(commandBuilder.ping()); + public RedisFuture pfadd(K key, V value, V... moreValues) { + return dispatch(commandBuilder.pfadd(key, value, moreValues)); } @Override - public RedisFuture readOnly() { - AsyncCommand cmd = dispatch(commandBuilder.readOnly()); - return cmd; + public RedisFuture pfadd(K key, V... values) { + return dispatch(commandBuilder.pfadd(key, values)); } @Override - public RedisFuture readWrite() { - AsyncCommand cmd = dispatch(commandBuilder.readWrite()); - return cmd; + public RedisFuture pfcount(K key, K... moreKeys) { + return dispatch(commandBuilder.pfcount(key, moreKeys)); + } + + @Override + public RedisFuture pfcount(K... keys) { + return dispatch(commandBuilder.pfcount(keys)); + } + + @Override + public RedisFuture pfmerge(K destkey, K sourcekey, K... moreSourceKeys) { + return dispatch(commandBuilder.pfmerge(destkey, sourcekey, moreSourceKeys)); + } + + @Override + public RedisFuture pfmerge(K destkey, K... sourcekeys) { + return dispatch(commandBuilder.pfmerge(destkey, sourcekeys)); + } + + @Override + public RedisFuture ping() { + return dispatch(commandBuilder.ping()); + } + + @Override + public RedisFuture psetex(K key, long milliseconds, V value) { + return dispatch(commandBuilder.psetex(key, milliseconds, value)); } @Override @@ -726,13 +1044,13 @@ public RedisFuture> pubsubChannels(K channel) { } @Override - public RedisFuture> pubsubNumsub(K... channels) { - return dispatch(commandBuilder.pubsubNumsub(channels)); + public RedisFuture pubsubNumpat() { + return dispatch(commandBuilder.pubsubNumpat()); } @Override - public RedisFuture pubsubNumpat() { - return dispatch(commandBuilder.pubsubNumpat()); + public RedisFuture> pubsubNumsub(K... channels) { + return dispatch(commandBuilder.pubsubNumsub(channels)); } @Override @@ -741,13 +1059,20 @@ public RedisFuture quit() { } @Override - public RedisFuture> role() { - return dispatch(commandBuilder.role()); + public RedisFuture randomkey() { + return dispatch(commandBuilder.randomkey()); } @Override - public RedisFuture randomkey() { - return dispatch(commandBuilder.randomkey()); + public RedisFuture readOnly() { + AsyncCommand cmd = dispatch(commandBuilder.readOnly()); + return cmd; + } + + @Override + public RedisFuture readWrite() { + AsyncCommand cmd = dispatch(commandBuilder.readWrite()); + return cmd; } @Override @@ -760,11 +1085,21 @@ public RedisFuture renamenx(K key, K newKey) { return dispatch(commandBuilder.renamenx(key, newKey)); } + @Override + public void reset() { + getConnection().reset(); + } + @Override public RedisFuture restore(K key, long ttl, byte[] value) { return dispatch(commandBuilder.restore(key, ttl, value)); } + @Override + public RedisFuture> role() { + return dispatch(commandBuilder.role()); + } + @Override public RedisFuture rpop(K key) { return dispatch(commandBuilder.rpop(key)); @@ -801,7 +1136,47 @@ public RedisFuture save() { } @Override - public RedisFuture scard(K key) { + public RedisFuture> scan() { + return dispatch(commandBuilder.scan()); + } + + @Override + public RedisFuture> scan(ScanArgs scanArgs) { + return dispatch(commandBuilder.scan(scanArgs)); + } + + @Override + public RedisFuture> scan(ScanCursor scanCursor, ScanArgs scanArgs) { + return dispatch(commandBuilder.scan(scanCursor, scanArgs)); + } + + @Override + public RedisFuture> scan(ScanCursor scanCursor) { + return dispatch(commandBuilder.scan(scanCursor)); + } + + @Override + public RedisFuture scan(KeyStreamingChannel channel) { + return dispatch(commandBuilder.scanStreaming(channel)); + } + + @Override + public RedisFuture scan(KeyStreamingChannel channel, ScanArgs scanArgs) { + return dispatch(commandBuilder.scanStreaming(channel, scanArgs)); + } + + @Override + public RedisFuture scan(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs) { + return dispatch(commandBuilder.scanStreaming(channel, scanCursor, scanArgs)); + } + + @Override + public RedisFuture scan(KeyStreamingChannel channel, ScanCursor scanCursor) { + return dispatch(commandBuilder.scanStreaming(channel, scanCursor)); + } + + @Override + public RedisFuture scard(K key) { return dispatch(commandBuilder.scard(key)); } @@ -850,10 +1225,6 @@ protected AsyncCommand selectAsync(int db) { return dispatch(commandBuilder.select(db)); } - public RedisFuture swapdb(int db1, int db2) { - return dispatch(commandBuilder.swapdb(db1, db2)); - } - @Override public RedisFuture set(K key, V value) { return dispatch(commandBuilder.set(key, value)); @@ -864,6 +1235,15 @@ public RedisFuture set(K key, V value, SetArgs setArgs) { return dispatch(commandBuilder.set(key, value, setArgs)); } + @Override + public void setAutoFlushCommands(boolean autoFlush) { + connection.setAutoFlushCommands(autoFlush); + } + + public void setTimeout(long timeout, TimeUnit unit) { + connection.setTimeout(timeout, unit); + } + @Override public RedisFuture setbit(K key, long offset, int value) { return dispatch(commandBuilder.setbit(key, offset, value)); @@ -874,11 +1254,6 @@ public RedisFuture setex(K key, long seconds, V value) { return dispatch(commandBuilder.setex(key, seconds, value)); } - @Override - public RedisFuture psetex(K key, long milliseconds, V value) { - return dispatch(commandBuilder.psetex(key, milliseconds, value)); - } - @Override public RedisFuture setnx(K key, V value) { return dispatch(commandBuilder.setnx(key, value)); @@ -919,11 +1294,6 @@ public RedisFuture sismember(K key, V member) { return dispatch(commandBuilder.sismember(key, member)); } - @Override - public RedisFuture smove(K source, K destination, V member) { - return dispatch(commandBuilder.smove(source, destination, member)); - } - @Override public RedisFuture slaveof(String host, int port) { return dispatch(commandBuilder.slaveof(host, port)); @@ -964,6 +1334,11 @@ public RedisFuture smembers(ValueStreamingChannel channel, K key) { return dispatch(commandBuilder.smembers(channel, key)); } + @Override + public RedisFuture smove(K source, K destination, V member) { + return dispatch(commandBuilder.smove(source, destination, member)); + } + @Override public RedisFuture> sort(K key) { return dispatch(commandBuilder.sort(key)); @@ -1019,6 +1394,51 @@ public RedisFuture srem(K key, V... members) { return dispatch(commandBuilder.srem(key, members)); } + @Override + public RedisFuture> sscan(K key) { + return dispatch(commandBuilder.sscan(key)); + } + + @Override + public RedisFuture> sscan(K key, ScanArgs scanArgs) { + return dispatch(commandBuilder.sscan(key, scanArgs)); + } + + @Override + public RedisFuture> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { + return dispatch(commandBuilder.sscan(key, scanCursor, scanArgs)); + } + + @Override + public RedisFuture> sscan(K key, ScanCursor scanCursor) { + return dispatch(commandBuilder.sscan(key, scanCursor)); + } + + @Override + public RedisFuture sscan(ValueStreamingChannel channel, K key) { + return dispatch(commandBuilder.sscanStreaming(channel, key)); + } + + @Override + public RedisFuture sscan(ValueStreamingChannel channel, K key, ScanArgs scanArgs) { + return dispatch(commandBuilder.sscanStreaming(channel, key, scanArgs)); + } + + @Override + public RedisFuture sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs) { + return dispatch(commandBuilder.sscanStreaming(channel, key, scanCursor, scanArgs)); + } + + @Override + public RedisFuture sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor) { + return dispatch(commandBuilder.sscanStreaming(channel, key, scanCursor)); + } + + @Override + public RedisFuture strlen(K key) { + return dispatch(commandBuilder.strlen(key)); + } + @Override public RedisFuture> sunion(K... keys) { return dispatch(commandBuilder.sunion(keys)); @@ -1034,14 +1454,18 @@ public RedisFuture sunionstore(K destination, K... keys) { return dispatch(commandBuilder.sunionstore(destination, keys)); } + public RedisFuture swapdb(int db1, int db2) { + return dispatch(commandBuilder.swapdb(db1, db2)); + } + @Override public RedisFuture sync() { return dispatch(commandBuilder.sync()); } @Override - public RedisFuture strlen(K key) { - return dispatch(commandBuilder.strlen(key)); + public RedisFuture> time() { + return dispatch(commandBuilder.time()); } @Override @@ -1064,8 +1488,12 @@ public RedisFuture type(K key) { } @Override - public RedisFuture watch(K... keys) { - return dispatch(commandBuilder.watch(keys)); + public RedisFuture unlink(K... keys) { + return dispatch(commandBuilder.unlink(keys)); + } + + public RedisFuture unlink(Iterable keys) { + return dispatch(commandBuilder.unlink(keys)); } @Override @@ -1073,6 +1501,16 @@ public RedisFuture unwatch() { return dispatch(commandBuilder.unwatch()); } + @Override + public RedisFuture waitForReplication(int replicas, long timeout) { + return dispatch(commandBuilder.wait(replicas, timeout)); + } + + @Override + public RedisFuture watch(K... keys) { + return dispatch(commandBuilder.watch(keys)); + } + @Override public RedisFuture zadd(K key, double score, V member) { return dispatch(commandBuilder.zadd(key, null, score, member)); @@ -1149,83 +1587,83 @@ public RedisFuture zinterstore(K destination, ZStoreArgs storeArgs, K... k } @Override - public RedisFuture> zrange(K key, long start, long stop) { - return dispatch(commandBuilder.zrange(key, start, stop)); + public RedisFuture zlexcount(K key, String min, String max) { + return dispatch(commandBuilder.zlexcount(key, min, max)); } @Override - public RedisFuture>> zrangeWithScores(K key, long start, long stop) { - return dispatch(commandBuilder.zrangeWithScores(key, start, stop)); + public RedisFuture zlexcount(K key, Range range) { + return dispatch(commandBuilder.zlexcount(key, range)); } @Override - public RedisFuture> zrangebyscore(K key, double min, double max) { - return dispatch(commandBuilder.zrangebyscore(key, min, max)); + public RedisFuture> zrange(K key, long start, long stop) { + return dispatch(commandBuilder.zrange(key, start, stop)); } @Override - public RedisFuture> zrangebyscore(K key, String min, String max) { - return dispatch(commandBuilder.zrangebyscore(key, min, max)); + public RedisFuture zrange(ValueStreamingChannel channel, K key, long start, long stop) { + return dispatch(commandBuilder.zrange(channel, key, start, stop)); } @Override - public RedisFuture> zrangebyscore(K key, Range range) { - return dispatch(commandBuilder.zrangebyscore(key, range, Limit.unlimited())); + public RedisFuture>> zrangeWithScores(K key, long start, long stop) { + return dispatch(commandBuilder.zrangeWithScores(key, start, stop)); } @Override - public RedisFuture> zrangebyscore(K key, double min, double max, long offset, long count) { - return dispatch(commandBuilder.zrangebyscore(key, min, max, offset, count)); + public RedisFuture zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { + return dispatch(commandBuilder.zrangeWithScores(channel, key, start, stop)); } @Override - public RedisFuture> zrangebyscore(K key, String min, String max, long offset, long count) { - return dispatch(commandBuilder.zrangebyscore(key, min, max, offset, count)); + public RedisFuture> zrangebylex(K key, String min, String max) { + return dispatch(commandBuilder.zrangebylex(key, min, max)); } @Override - public RedisFuture> zrangebyscore(K key, Range range, Limit limit) { - return dispatch(commandBuilder.zrangebyscore(key, range, limit)); + public RedisFuture> zrangebylex(K key, Range range) { + return dispatch(commandBuilder.zrangebylex(key, range, Limit.unlimited())); } @Override - public RedisFuture>> zrangebyscoreWithScores(K key, double min, double max) { - return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max)); + public RedisFuture> zrangebylex(K key, String min, String max, long offset, long count) { + return dispatch(commandBuilder.zrangebylex(key, min, max, offset, count)); } @Override - public RedisFuture>> zrangebyscoreWithScores(K key, String min, String max) { - return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max)); + public RedisFuture> zrangebylex(K key, Range range, Limit limit) { + return dispatch(commandBuilder.zrangebylex(key, range, limit)); } @Override - public RedisFuture>> zrangebyscoreWithScores(K key, Range range) { - return dispatch(commandBuilder.zrangebyscoreWithScores(key, range, Limit.unlimited())); + public RedisFuture> zrangebyscore(K key, double min, double max) { + return dispatch(commandBuilder.zrangebyscore(key, min, max)); } @Override - public RedisFuture>> zrangebyscoreWithScores(K key, double min, double max, long offset, long count) { - return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); + public RedisFuture> zrangebyscore(K key, String min, String max) { + return dispatch(commandBuilder.zrangebyscore(key, min, max)); } @Override - public RedisFuture>> zrangebyscoreWithScores(K key, String min, String max, long offset, long count) { - return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); + public RedisFuture> zrangebyscore(K key, Range range) { + return dispatch(commandBuilder.zrangebyscore(key, range, Limit.unlimited())); } @Override - public RedisFuture>> zrangebyscoreWithScores(K key, Range range, Limit limit) { - return dispatch(commandBuilder.zrangebyscoreWithScores(key, range, limit)); + public RedisFuture> zrangebyscore(K key, double min, double max, long offset, long count) { + return dispatch(commandBuilder.zrangebyscore(key, min, max, offset, count)); } @Override - public RedisFuture zrange(ValueStreamingChannel channel, K key, long start, long stop) { - return dispatch(commandBuilder.zrange(channel, key, start, stop)); + public RedisFuture> zrangebyscore(K key, String min, String max, long offset, long count) { + return dispatch(commandBuilder.zrangebyscore(key, min, max, offset, count)); } @Override - public RedisFuture zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { - return dispatch(commandBuilder.zrangeWithScores(channel, key, start, stop)); + public RedisFuture> zrangebyscore(K key, Range range, Limit limit) { + return dispatch(commandBuilder.zrangebyscore(key, range, limit)); } @Override @@ -1260,6 +1698,36 @@ public RedisFuture zrangebyscore(ValueStreamingChannel channel, K key, return dispatch(commandBuilder.zrangebyscore(channel, key, range, limit)); } + @Override + public RedisFuture>> zrangebyscoreWithScores(K key, double min, double max) { + return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max)); + } + + @Override + public RedisFuture>> zrangebyscoreWithScores(K key, String min, String max) { + return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max)); + } + + @Override + public RedisFuture>> zrangebyscoreWithScores(K key, Range range) { + return dispatch(commandBuilder.zrangebyscoreWithScores(key, range, Limit.unlimited())); + } + + @Override + public RedisFuture>> zrangebyscoreWithScores(K key, double min, double max, long offset, long count) { + return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); + } + + @Override + public RedisFuture>> zrangebyscoreWithScores(K key, String min, String max, long offset, long count) { + return dispatch(commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); + } + + @Override + public RedisFuture>> zrangebyscoreWithScores(K key, Range range, Limit limit) { + return dispatch(commandBuilder.zrangebyscoreWithScores(key, range, limit)); + } + @Override public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max) { return dispatch(commandBuilder.zrangebyscoreWithScores(channel, key, min, max)); @@ -1271,7 +1739,8 @@ public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel } @Override - public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range) { + public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range) { return dispatch(commandBuilder.zrangebyscoreWithScores(channel, key, range, Limit.unlimited())); } @@ -1288,8 +1757,8 @@ public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel } @Override - public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, - Limit limit) { + public RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range, Limit limit) { return dispatch(commandBuilder.zrangebyscoreWithScores(channel, key, range, limit)); } @@ -1303,6 +1772,16 @@ public RedisFuture zrem(K key, V... members) { return dispatch(commandBuilder.zrem(key, members)); } + @Override + public RedisFuture zremrangebylex(K key, String min, String max) { + return dispatch(commandBuilder.zremrangebylex(key, min, max)); + } + + @Override + public RedisFuture zremrangebylex(K key, Range range) { + return dispatch(commandBuilder.zremrangebylex(key, range)); + } + @Override public RedisFuture zremrangebyrank(K key, long start, long stop) { return dispatch(commandBuilder.zremrangebyrank(key, start, stop)); @@ -1328,11 +1807,21 @@ public RedisFuture> zrevrange(K key, long start, long stop) { return dispatch(commandBuilder.zrevrange(key, start, stop)); } + @Override + public RedisFuture zrevrange(ValueStreamingChannel channel, K key, long start, long stop) { + return dispatch(commandBuilder.zrevrange(channel, key, start, stop)); + } + @Override public RedisFuture>> zrevrangeWithScores(K key, long start, long stop) { return dispatch(commandBuilder.zrevrangeWithScores(key, start, stop)); } + @Override + public RedisFuture zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { + return dispatch(commandBuilder.zrevrangeWithScores(channel, key, start, stop)); + } + @Override public RedisFuture> zrevrangebylex(K key, Range range) { return dispatch(commandBuilder.zrevrangebylex(key, range, Limit.unlimited())); @@ -1374,75 +1863,66 @@ public RedisFuture> zrevrangebyscore(K key, Range rang } @Override - public RedisFuture>> zrevrangebyscoreWithScores(K key, double max, double min) { - return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min)); - } - - @Override - public RedisFuture>> zrevrangebyscoreWithScores(K key, String max, String min) { - return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min)); - } - - @Override - public RedisFuture>> zrevrangebyscoreWithScores(K key, Range range) { - return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, range, Limit.unlimited())); + public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min) { + return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min)); } @Override - public RedisFuture>> zrevrangebyscoreWithScores(K key, double max, double min, long offset, long count) { - return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); + public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min) { + return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min)); } @Override - public RedisFuture>> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count) { - return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); + public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, Range range) { + return dispatch(commandBuilder.zrevrangebyscore(channel, key, range, Limit.unlimited())); } @Override - public RedisFuture>> zrevrangebyscoreWithScores(K key, Range range, Limit limit) { - return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, range, limit)); + public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min, long offset, + long count) { + return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min, offset, count)); } @Override - public RedisFuture zrevrange(ValueStreamingChannel channel, K key, long start, long stop) { - return dispatch(commandBuilder.zrevrange(channel, key, start, stop)); + public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min, long offset, + long count) { + return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min, offset, count)); } @Override - public RedisFuture zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { - return dispatch(commandBuilder.zrevrangeWithScores(channel, key, start, stop)); + public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, Range range, + Limit limit) { + return dispatch(commandBuilder.zrevrangebyscore(channel, key, range, limit)); } @Override - public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min) { - return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min)); + public RedisFuture>> zrevrangebyscoreWithScores(K key, double max, double min) { + return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min)); } @Override - public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min) { - return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min)); + public RedisFuture>> zrevrangebyscoreWithScores(K key, String max, String min) { + return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min)); } @Override - public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, Range range) { - return dispatch(commandBuilder.zrevrangebyscore(channel, key, range, Limit.unlimited())); + public RedisFuture>> zrevrangebyscoreWithScores(K key, Range range) { + return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, range, Limit.unlimited())); } @Override - public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min, long offset, - long count) { - return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min, offset, count)); + public RedisFuture>> zrevrangebyscoreWithScores(K key, double max, double min, long offset, long count) { + return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); } @Override - public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min, long offset, - long count) { - return dispatch(commandBuilder.zrevrangebyscore(channel, key, max, min, offset, count)); + public RedisFuture>> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count) { + return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); } @Override - public RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, Range range, Limit limit) { - return dispatch(commandBuilder.zrevrangebyscore(channel, key, range, limit)); + public RedisFuture>> zrevrangebyscoreWithScores(K key, Range range, Limit limit) { + return dispatch(commandBuilder.zrevrangebyscoreWithScores(key, range, limit)); } @Override @@ -1456,7 +1936,8 @@ public RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel< } @Override - public RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range) { + public RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range) { return dispatch(commandBuilder.zrevrangebyscoreWithScores(channel, key, range, Limit.unlimited())); } @@ -1473,8 +1954,8 @@ public RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel< } @Override - public RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, - Limit limit) { + public RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range, Limit limit) { return dispatch(commandBuilder.zrevrangebyscoreWithScores(channel, key, range, limit)); } @@ -1483,142 +1964,6 @@ public RedisFuture zrevrank(K key, V member) { return dispatch(commandBuilder.zrevrank(key, member)); } - @Override - public RedisFuture zscore(K key, V member) { - return dispatch(commandBuilder.zscore(key, member)); - } - - @Override - public RedisFuture zunionstore(K destination, K... keys) { - return dispatch(commandBuilder.zunionstore(destination, keys)); - } - - @Override - public RedisFuture zunionstore(K destination, ZStoreArgs storeArgs, K... keys) { - return dispatch(commandBuilder.zunionstore(destination, storeArgs, keys)); - } - - @Override - public RedisFuture> scan() { - return dispatch(commandBuilder.scan()); - } - - @Override - public RedisFuture> scan(ScanArgs scanArgs) { - return dispatch(commandBuilder.scan(scanArgs)); - } - - @Override - public RedisFuture> scan(ScanCursor scanCursor, ScanArgs scanArgs) { - return dispatch(commandBuilder.scan(scanCursor, scanArgs)); - } - - @Override - public RedisFuture> scan(ScanCursor scanCursor) { - return dispatch(commandBuilder.scan(scanCursor)); - } - - @Override - public RedisFuture scan(KeyStreamingChannel channel) { - return dispatch(commandBuilder.scanStreaming(channel)); - } - - @Override - public RedisFuture scan(KeyStreamingChannel channel, ScanArgs scanArgs) { - return dispatch(commandBuilder.scanStreaming(channel, scanArgs)); - } - - @Override - public RedisFuture scan(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs) { - return dispatch(commandBuilder.scanStreaming(channel, scanCursor, scanArgs)); - } - - @Override - public RedisFuture scan(KeyStreamingChannel channel, ScanCursor scanCursor) { - return dispatch(commandBuilder.scanStreaming(channel, scanCursor)); - } - - @Override - public RedisFuture> sscan(K key) { - return dispatch(commandBuilder.sscan(key)); - } - - @Override - public RedisFuture> sscan(K key, ScanArgs scanArgs) { - return dispatch(commandBuilder.sscan(key, scanArgs)); - } - - @Override - public RedisFuture> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - return dispatch(commandBuilder.sscan(key, scanCursor, scanArgs)); - } - - @Override - public RedisFuture> sscan(K key, ScanCursor scanCursor) { - return dispatch(commandBuilder.sscan(key, scanCursor)); - } - - @Override - public RedisFuture sscan(ValueStreamingChannel channel, K key) { - return dispatch(commandBuilder.sscanStreaming(channel, key)); - } - - @Override - public RedisFuture sscan(ValueStreamingChannel channel, K key, ScanArgs scanArgs) { - return dispatch(commandBuilder.sscanStreaming(channel, key, scanArgs)); - } - - @Override - public RedisFuture sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs) { - return dispatch(commandBuilder.sscanStreaming(channel, key, scanCursor, scanArgs)); - } - - @Override - public RedisFuture sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor) { - return dispatch(commandBuilder.sscanStreaming(channel, key, scanCursor)); - } - - @Override - public RedisFuture> hscan(K key) { - return dispatch(commandBuilder.hscan(key)); - } - - @Override - public RedisFuture> hscan(K key, ScanArgs scanArgs) { - return dispatch(commandBuilder.hscan(key, scanArgs)); - } - - @Override - public RedisFuture> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - return dispatch(commandBuilder.hscan(key, scanCursor, scanArgs)); - } - - @Override - public RedisFuture> hscan(K key, ScanCursor scanCursor) { - return dispatch(commandBuilder.hscan(key, scanCursor)); - } - - @Override - public RedisFuture hscan(KeyValueStreamingChannel channel, K key) { - return dispatch(commandBuilder.hscanStreaming(channel, key)); - } - - @Override - public RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs) { - return dispatch(commandBuilder.hscanStreaming(channel, key, scanArgs)); - } - - @Override - public RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, - ScanArgs scanArgs) { - return dispatch(commandBuilder.hscanStreaming(channel, key, scanCursor, scanArgs)); - } - - @Override - public RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor) { - return dispatch(commandBuilder.hscanStreaming(channel, key, scanCursor)); - } - @Override public RedisFuture> zscan(K key) { return dispatch(commandBuilder.zscan(key)); @@ -1661,358 +2006,17 @@ public RedisFuture zscan(ScoredValueStreamingChannel channe } @Override - public String digest(V script) { - return LettuceStrings.digest(codec.encodeValue(script)); - } - - @Override - public RedisFuture> time() { - return dispatch(commandBuilder.time()); - } - - @Override - public RedisFuture waitForReplication(int replicas, long timeout) { - return dispatch(commandBuilder.wait(replicas, timeout)); - } - - @Override - public RedisFuture pfadd(K key, V value, V... moreValues) { - return dispatch(commandBuilder.pfadd(key, value, moreValues)); - } - - @Override - public RedisFuture pfadd(K key, V... values) { - return dispatch(commandBuilder.pfadd(key, values)); - } - - @Override - public RedisFuture pfmerge(K destkey, K sourcekey, K... moreSourceKeys) { - return dispatch(commandBuilder.pfmerge(destkey, sourcekey, moreSourceKeys)); - } - - @Override - public RedisFuture pfmerge(K destkey, K... sourcekeys) { - return dispatch(commandBuilder.pfmerge(destkey, sourcekeys)); - } - - @Override - public RedisFuture pfcount(K key, K... moreKeys) { - return dispatch(commandBuilder.pfcount(key, moreKeys)); - } - - @Override - public RedisFuture pfcount(K... keys) { - return dispatch(commandBuilder.pfcount(keys)); - } - - @Override - public RedisFuture clusterBumpepoch() { - return dispatch(commandBuilder.clusterBumpepoch()); - } - - @Override - public RedisFuture clusterMeet(String ip, int port) { - return dispatch(commandBuilder.clusterMeet(ip, port)); + public RedisFuture zscore(K key, V member) { + return dispatch(commandBuilder.zscore(key, member)); } @Override - public RedisFuture clusterForget(String nodeId) { - return dispatch(commandBuilder.clusterForget(nodeId)); + public RedisFuture zunionstore(K destination, K... keys) { + return dispatch(commandBuilder.zunionstore(destination, keys)); } @Override - public RedisFuture clusterAddSlots(int... slots) { - return dispatch(commandBuilder.clusterAddslots(slots)); - } - - @Override - public RedisFuture clusterDelSlots(int... slots) { - return dispatch(commandBuilder.clusterDelslots(slots)); - } - - @Override - public RedisFuture clusterInfo() { - return dispatch(commandBuilder.clusterInfo()); - } - - @Override - public RedisFuture clusterMyId() { - return dispatch(commandBuilder.clusterMyId()); - } - - @Override - public RedisFuture clusterNodes() { - return dispatch(commandBuilder.clusterNodes()); - } - - @Override - public RedisFuture> clusterGetKeysInSlot(int slot, int count) { - return dispatch(commandBuilder.clusterGetKeysInSlot(slot, count)); - } - - @Override - public RedisFuture clusterCountKeysInSlot(int slot) { - return dispatch(commandBuilder.clusterCountKeysInSlot(slot)); - } - - @Override - public RedisFuture clusterCountFailureReports(String nodeId) { - return dispatch(commandBuilder.clusterCountFailureReports(nodeId)); - } - - @Override - public RedisFuture clusterKeyslot(K key) { - return dispatch(commandBuilder.clusterKeyslot(key)); - } - - @Override - public RedisFuture clusterSaveconfig() { - return dispatch(commandBuilder.clusterSaveconfig()); - } - - @Override - public RedisFuture clusterSetConfigEpoch(long configEpoch) { - return dispatch(commandBuilder.clusterSetConfigEpoch(configEpoch)); - } - - @Override - public RedisFuture> clusterSlots() { - return dispatch(commandBuilder.clusterSlots()); - } - - @Override - public RedisFuture clusterSetSlotNode(int slot, String nodeId) { - return dispatch(commandBuilder.clusterSetSlotNode(slot, nodeId)); - } - - @Override - public RedisFuture clusterSetSlotStable(int slot) { - return dispatch(commandBuilder.clusterSetSlotStable(slot)); - } - - @Override - public RedisFuture clusterSetSlotMigrating(int slot, String nodeId) { - return dispatch(commandBuilder.clusterSetSlotMigrating(slot, nodeId)); - } - - @Override - public RedisFuture clusterSetSlotImporting(int slot, String nodeId) { - return dispatch(commandBuilder.clusterSetSlotImporting(slot, nodeId)); - } - - @Override - public RedisFuture clusterFailover(boolean force) { - return dispatch(commandBuilder.clusterFailover(force)); - } - - @Override - public RedisFuture clusterReset(boolean hard) { - return dispatch(commandBuilder.clusterReset(hard)); - } - - @Override - public RedisFuture asking() { - return dispatch(commandBuilder.asking()); - } - - @Override - public RedisFuture clusterReplicate(String nodeId) { - return dispatch(commandBuilder.clusterReplicate(nodeId)); - } - - @Override - public RedisFuture clusterFlushslots() { - return dispatch(commandBuilder.clusterFlushslots()); - } - - @Override - public RedisFuture> clusterSlaves(String nodeId) { - return dispatch(commandBuilder.clusterSlaves(nodeId)); - } - - @Override - public RedisFuture zlexcount(K key, String min, String max) { - return dispatch(commandBuilder.zlexcount(key, min, max)); - } - - @Override - public RedisFuture zlexcount(K key, Range range) { - return dispatch(commandBuilder.zlexcount(key, range)); - } - - @Override - public RedisFuture zremrangebylex(K key, String min, String max) { - return dispatch(commandBuilder.zremrangebylex(key, min, max)); - } - - @Override - public RedisFuture zremrangebylex(K key, Range range) { - return dispatch(commandBuilder.zremrangebylex(key, range)); - } - - @Override - public RedisFuture> zrangebylex(K key, String min, String max) { - return dispatch(commandBuilder.zrangebylex(key, min, max)); - } - - @Override - public RedisFuture> zrangebylex(K key, Range range) { - return dispatch(commandBuilder.zrangebylex(key, range, Limit.unlimited())); - } - - @Override - public RedisFuture> zrangebylex(K key, String min, String max, long offset, long count) { - return dispatch(commandBuilder.zrangebylex(key, min, max, offset, count)); - } - - @Override - public RedisFuture> zrangebylex(K key, Range range, Limit limit) { - return dispatch(commandBuilder.zrangebylex(key, range, limit)); - } - - @Override - public RedisFuture geoadd(K key, double longitude, double latitude, V member) { - return dispatch(commandBuilder.geoadd(key, longitude, latitude, member)); - } - - @Override - public RedisFuture geoadd(K key, Object... lngLatMember) { - return dispatch(commandBuilder.geoadd(key, lngLatMember)); - } - - @Override - public RedisFuture> geohash(K key, V... members) { - return dispatch(commandBuilder.geohash(key, members)); - } - - @Override - public RedisFuture> georadius(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { - return dispatch(commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, unit.name())); - } - - protected RedisFuture> georadius_ro(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { - return dispatch(commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, unit.name())); - } - - @Override - public RedisFuture>> georadius(K key, double longitude, double latitude, double distance, - GeoArgs.Unit unit, GeoArgs geoArgs) { - return dispatch(commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, unit.name(), geoArgs)); - } - - protected RedisFuture>> georadius_ro(K key, double longitude, double latitude, double distance, - GeoArgs.Unit unit, GeoArgs geoArgs) { - return dispatch(commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, unit.name(), geoArgs)); - } - - @Override - public RedisFuture georadius(K key, double longitude, double latitude, double distance, Unit unit, - GeoRadiusStoreArgs geoRadiusStoreArgs) { - return dispatch(commandBuilder.georadius(key, longitude, latitude, distance, unit.name(), geoRadiusStoreArgs)); - } - - @Override - public RedisFuture> georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit) { - return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, unit.name())); - } - - protected RedisFuture> georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit) { - return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, unit.name())); - } - - @Override - public RedisFuture>> georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit, - GeoArgs geoArgs) { - return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, unit.name(), geoArgs)); - } - - protected RedisFuture>> georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit, - GeoArgs geoArgs) { - return dispatch(commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, unit.name(), geoArgs)); - } - - @Override - public RedisFuture georadiusbymember(K key, V member, double distance, Unit unit, - GeoRadiusStoreArgs geoRadiusStoreArgs) { - return dispatch(commandBuilder.georadiusbymember(key, member, distance, unit.name(), geoRadiusStoreArgs)); - } - - @Override - public RedisFuture> geopos(K key, V... members) { - return dispatch(commandBuilder.geopos(key, members)); - } - - @Override - public RedisFuture geodist(K key, V from, V to, GeoArgs.Unit unit) { - return dispatch(commandBuilder.geodist(key, from, to, unit)); - } - - @Override - public RedisFuture dispatch(ProtocolKeyword type, CommandOutput output) { - - LettuceAssert.notNull(type, "Command type must not be null"); - LettuceAssert.notNull(output, "CommandOutput type must not be null"); - - return dispatch(new AsyncCommand<>(new Command<>(type, output))); - } - - @Override - public RedisFuture 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 dispatch(new AsyncCommand<>(new Command<>(type, output, args))); - } - - protected RedisFuture dispatch(CommandType type, CommandOutput output) { - return dispatch(type, output, null); - } - - protected RedisFuture dispatch(CommandType type, CommandOutput output, CommandArgs args) { - return dispatch(new AsyncCommand<>(new Command<>(type, output, args))); - } - - public AsyncCommand dispatch(RedisCommand cmd) { - AsyncCommand asyncCommand = new AsyncCommand<>(cmd); - RedisCommand dispatched = connection.dispatch(asyncCommand); - if (dispatched instanceof AsyncCommand) { - return (AsyncCommand) dispatched; - } - return asyncCommand; - } - - public void setTimeout(long timeout, TimeUnit unit) { - connection.setTimeout(timeout, unit); - } - - @Override - public void close() { - connection.close(); - } - - @Override - public boolean isOpen() { - return connection.isOpen(); - } - - @Override - public void reset() { - getConnection().reset(); - } - - public StatefulConnection getConnection() { - return connection; - } - - @Override - public void setAutoFlushCommands(boolean autoFlush) { - connection.setAutoFlushCommands(autoFlush); - } - - @Override - public void flushCommands() { - connection.flushCommands(); + public RedisFuture zunionstore(K destination, ZStoreArgs storeArgs, K... keys) { + return dispatch(commandBuilder.zunionstore(destination, storeArgs, keys)); } } diff --git a/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java b/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java index b70180ee68..5044b34373 100644 --- a/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java +++ b/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2011-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,10 +48,10 @@ public abstract class AbstractRedisReactiveCommands implements RedisHashRe RedisServerReactiveCommands, RedisHLLReactiveCommands, BaseRedisReactiveCommands, RedisTransactionalReactiveCommands, RedisGeoReactiveCommands, RedisClusterReactiveCommands { - protected MultiOutput multi; - protected RedisCommandBuilder commandBuilder; - protected RedisCodec codec; protected StatefulConnection connection; + protected RedisCodec codec; + protected RedisCommandBuilder commandBuilder; + protected MultiOutput multi; /** * Initialize a new instance. @@ -70,10 +70,14 @@ public Observable append(K key, V value) { return createObservable(() -> commandBuilder.append(key, value)); } + @Override + public Observable asking() { + return createObservable(commandBuilder::asking); + } + @Override public Observable auth(String password) { return createObservable(() -> commandBuilder.auth(password)); - } @Override @@ -101,16 +105,6 @@ public Observable bitfield(K key, BitFieldArgs args) { return createDissolvingObservable(() -> commandBuilder.bitfield(key, args)); } - @Override - public Observable bitpos(K key, boolean state) { - return createObservable(() -> commandBuilder.bitpos(key, state)); - } - - @Override - public Observable bitpos(K key, boolean state, long start, long end) { - return createObservable(() -> commandBuilder.bitpos(key, state, start, end)); - } - @Override public Observable bitopAnd(K destination, K... keys) { return createObservable(() -> commandBuilder.bitopAnd(destination, keys)); @@ -131,6 +125,16 @@ public Observable bitopXor(K destination, K... keys) { return createObservable(() -> commandBuilder.bitopXor(destination, keys)); } + @Override + public Observable bitpos(K key, boolean state) { + return createObservable(() -> commandBuilder.bitpos(key, state)); + } + + @Override + public Observable bitpos(K key, boolean state, long start, long end) { + return createObservable(() -> commandBuilder.bitpos(key, state, start, end)); + } + @Override public Observable> blpop(long timeout, K... keys) { return createObservable(() -> commandBuilder.blpop(timeout, keys)); @@ -151,11 +155,6 @@ public Observable clientGetname() { return createObservable(commandBuilder::clientGetname); } - @Override - public Observable clientSetname(K name) { - return createObservable(() -> commandBuilder.clientSetname(name)); - } - @Override public Observable clientKill(String addr) { return createObservable(() -> commandBuilder.clientKill(addr)); @@ -166,14 +165,144 @@ public Observable clientKill(KillArgs killArgs) { return createObservable(() -> commandBuilder.clientKill(killArgs)); } + @Override + public Observable clientList() { + return createObservable(commandBuilder::clientList); + } + @Override public Observable clientPause(long timeout) { return createObservable(() -> commandBuilder.clientPause(timeout)); } @Override - public Observable clientList() { - return createObservable(commandBuilder::clientList); + public Observable clientSetname(K name) { + return createObservable(() -> commandBuilder.clientSetname(name)); + } + + @Override + public void close() { + connection.close(); + } + + @Override + public Observable clusterAddSlots(int... slots) { + return createObservable(() -> commandBuilder.clusterAddslots(slots)); + } + + @Override + public Observable clusterBumpepoch() { + return createObservable(() -> commandBuilder.clusterBumpepoch()); + } + + @Override + public Observable clusterCountFailureReports(String nodeId) { + return createObservable(() -> commandBuilder.clusterCountFailureReports(nodeId)); + } + + @Override + public Observable clusterCountKeysInSlot(int slot) { + return createObservable(() -> commandBuilder.clusterCountKeysInSlot(slot)); + } + + @Override + public Observable clusterDelSlots(int... slots) { + return createObservable(() -> commandBuilder.clusterDelslots(slots)); + } + + @Override + public Observable clusterFailover(boolean force) { + return createObservable(() -> commandBuilder.clusterFailover(force)); + } + + @Override + public Observable clusterFlushslots() { + return createObservable(commandBuilder::clusterFlushslots); + } + + @Override + public Observable clusterForget(String nodeId) { + return createObservable(() -> commandBuilder.clusterForget(nodeId)); + } + + @Override + public Observable clusterGetKeysInSlot(int slot, int count) { + return createDissolvingObservable(() -> commandBuilder.clusterGetKeysInSlot(slot, count)); + } + + @Override + public Observable clusterInfo() { + return createObservable(commandBuilder::clusterInfo); + } + + @Override + public Observable clusterKeyslot(K key) { + return createObservable(() -> commandBuilder.clusterKeyslot(key)); + } + + @Override + public Observable clusterMeet(String ip, int port) { + return createObservable(() -> commandBuilder.clusterMeet(ip, port)); + } + + @Override + public Observable clusterMyId() { + return createObservable(commandBuilder::clusterMyId); + } + + @Override + public Observable clusterNodes() { + return createObservable(commandBuilder::clusterNodes); + } + + @Override + public Observable clusterReplicate(String nodeId) { + return createObservable(() -> commandBuilder.clusterReplicate(nodeId)); + } + + @Override + public Observable clusterReset(boolean hard) { + return createObservable(() -> commandBuilder.clusterReset(hard)); + } + + @Override + public Observable clusterSaveconfig() { + return createObservable(() -> commandBuilder.clusterSaveconfig()); + } + + @Override + public Observable clusterSetConfigEpoch(long configEpoch) { + return createObservable(() -> commandBuilder.clusterSetConfigEpoch(configEpoch)); + } + + @Override + public Observable clusterSetSlotImporting(int slot, String nodeId) { + return createObservable(() -> commandBuilder.clusterSetSlotImporting(slot, nodeId)); + } + + @Override + public Observable clusterSetSlotMigrating(int slot, String nodeId) { + return createObservable(() -> commandBuilder.clusterSetSlotMigrating(slot, nodeId)); + } + + @Override + public Observable clusterSetSlotNode(int slot, String nodeId) { + return createObservable(() -> commandBuilder.clusterSetSlotNode(slot, nodeId)); + } + + @Override + public Observable clusterSetSlotStable(int slot) { + return createObservable(() -> commandBuilder.clusterSetSlotStable(slot)); + } + + @Override + public Observable clusterSlaves(String nodeId) { + return createDissolvingObservable(() -> commandBuilder.clusterSlaves(nodeId)); + } + + @Override + public Observable clusterSlots() { + return createDissolvingObservable(commandBuilder::clusterSlots); } @Override @@ -181,6 +310,11 @@ public Observable command() { return createDissolvingObservable(commandBuilder::command); } + @Override + public Observable commandCount() { + return createObservable(commandBuilder::commandCount); + } + @Override public Observable commandInfo(String... commands) { return createDissolvingObservable(() -> commandBuilder.commandInfo(commands)); @@ -196,11 +330,6 @@ public Observable commandInfo(CommandType... commands) { return commandInfo(stringCommands); } - @Override - public Observable commandCount() { - return createObservable(commandBuilder::commandCount); - } - @Override public Observable configGet(String parameter) { return createDissolvingObservable(() -> commandBuilder.configGet(parameter)); @@ -211,14 +340,33 @@ public Observable configResetstat() { return createObservable(commandBuilder::configResetstat); } + @Override + public Observable configRewrite() { + return createObservable(commandBuilder::configRewrite); + } + @Override public Observable configSet(String parameter, String value) { return createObservable(() -> commandBuilder.configSet(parameter, value)); } - @Override - public Observable configRewrite() { - return createObservable(commandBuilder::configRewrite); + @SuppressWarnings("unchecked") + public R createDissolvingObservable(Supplier> commandSupplier) { + return (R) Observable.create(new ReactiveCommandDispatcher<>(commandSupplier, connection, true)); + } + + @SuppressWarnings("unchecked") + public R createDissolvingObservable(CommandType type, CommandOutput output, CommandArgs args) { + return (R) Observable + .create(new ReactiveCommandDispatcher<>(() -> new Command<>(type, output, args), connection, true)); + } + + protected Observable createObservable(CommandType type, CommandOutput output, CommandArgs args) { + return createObservable(() -> new Command<>(type, output, args)); + } + + public Observable createObservable(Supplier> commandSupplier) { + return Observable.create(new ReactiveCommandDispatcher<>(commandSupplier, connection, false)); } @Override @@ -286,12 +434,8 @@ public Observable del(Iterable keys) { } @Override - public Observable unlink(K... keys) { - return createObservable(() -> commandBuilder.unlink(keys)); - } - - public Observable unlink(Iterable keys) { - return createObservable(() -> commandBuilder.unlink(keys)); + public String digest(V script) { + return LettuceStrings.digest(codec.encodeValue(script)); } @Override @@ -299,6 +443,25 @@ public Observable discard() { return createObservable(commandBuilder::discard); } + @Override + public Observable dispatch(ProtocolKeyword type, CommandOutput output) { + + LettuceAssert.notNull(type, "Command type must not be null"); + LettuceAssert.notNull(output, "CommandOutput type must not be null"); + + return createDissolvingObservable(() -> new Command<>(type, output)); + } + + @Override + public Observable 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 createDissolvingObservable(() -> new Command<>(type, output, args)); + } + @Override public Observable dump(K key) { return createObservable(() -> commandBuilder.dump(key)); @@ -333,6 +496,11 @@ public Observable evalsha(String digest, ScriptOutputType type, K[] keys, return (Observable) createObservable(() -> commandBuilder.evalsha(digest, type, keys, values)); } + @Override + public Observable exec() { + return createDissolvingObservable(EXEC, null, null); + } + public Observable exists(K key) { return createObservable(() -> commandBuilder.exists(key)); } @@ -361,11 +529,6 @@ public Observable expireat(K key, Date timestamp) { return expireat(key, timestamp.getTime() / 1000); } - @Override - public Observable exec() { - return createDissolvingObservable(EXEC, null, null); - } - @Override public Observable flushall() { return createObservable(commandBuilder::flushall); @@ -387,23 +550,145 @@ public Observable flushdbAsync() { } @Override - public Observable get(K key) { - return createObservable(() -> commandBuilder.get(key)); + public Observable geoadd(K key, double longitude, double latitude, V member) { + return createObservable(() -> commandBuilder.geoadd(key, longitude, latitude, member)); } @Override - public Observable getbit(K key, long offset) { - return createObservable(() -> commandBuilder.getbit(key, offset)); + public Observable geoadd(K key, Object... lngLatMember) { + return createDissolvingObservable(() -> commandBuilder.geoadd(key, lngLatMember)); } @Override - public Observable getrange(K key, long start, long end) { - return createObservable(() -> commandBuilder.getrange(key, start, end)); + public Observable geodist(K key, V from, V to, GeoArgs.Unit unit) { + return createDissolvingObservable(() -> commandBuilder.geodist(key, from, to, unit)); } @Override - public Observable getset(K key, V value) { - return createObservable(() -> commandBuilder.getset(key, value)); + public Observable geohash(K key, V... members) { + return createDissolvingObservable(() -> commandBuilder.geohash(key, members)); + } + + @Override + public Observable geopos(K key, V... members) { + return createDissolvingObservable(() -> commandBuilder.geopos(key, members)); + } + + @Override + public Observable georadius(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { + return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, + unit.name())); + } + + @Override + public Observable> georadius(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit, + GeoArgs geoArgs) { + return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, + unit.name(), geoArgs)); + } + + @Override + public Observable georadius(K key, double longitude, double latitude, double distance, Unit unit, + GeoRadiusStoreArgs geoRadiusStoreArgs) { + return createDissolvingObservable(() -> commandBuilder.georadius(key, longitude, latitude, distance, unit.name(), + geoRadiusStoreArgs)); + } + + protected Observable georadius_ro(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { + return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, + unit.name())); + } + + protected Observable> georadius_ro(K key, double longitude, double latitude, double distance, + GeoArgs.Unit unit, GeoArgs geoArgs) { + return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, + unit.name(), geoArgs)); + } + + @Override + public Observable georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit) { + return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, + unit.name())); + } + + @Override + public Observable> georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit, GeoArgs geoArgs) { + return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, + unit.name(), geoArgs)); + } + + @Override + public Observable georadiusbymember(K key, V member, double distance, Unit unit, + GeoRadiusStoreArgs geoRadiusStoreArgs) { + return createDissolvingObservable(() -> commandBuilder.georadiusbymember(key, member, distance, unit.name(), + geoRadiusStoreArgs)); + } + + protected Observable georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit) { + return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, + unit.name())); + } + + protected Observable> georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit, GeoArgs geoArgs) { + return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, + unit.name(), geoArgs)); + } + + @Override + public Observable get(K key) { + return createObservable(() -> commandBuilder.get(key)); + } + + public StatefulConnection getConnection() { + return connection; + } + + /** + * Emits just {@link Success#Success} or the {@link Throwable} after the inner observable is completed. + * + * @param observable inner observable + * @param used for type inference + * @return Success observable + */ + protected Observable getSuccessObservable(final Observable observable) { + return Observable.create(new Observable.OnSubscribe() { + @Override + public void call(Subscriber subscriber) { + + observable.subscribe(new Subscriber() { + @Override + public void onCompleted() { + subscriber.onNext(Success.Success); + subscriber.onCompleted(); + } + + @Override + public void onError(Throwable throwable) { + subscriber.onError(throwable); + } + + @Override + public void onNext(Object k) { + + } + }); + } + }); + } + + @Override + public Observable getbit(K key, long offset) { + return createObservable(() -> commandBuilder.getbit(key, offset)); + } + + @Override + public Observable getrange(K key, long start, long end) { + return createObservable(() -> commandBuilder.getrange(key, start, end)); + } + + @Override + public Observable getset(K key, V value) { + return createObservable(() -> commandBuilder.getset(key, value)); } @Override @@ -422,23 +707,23 @@ public Observable hget(K key, K field) { } @Override - public Observable hincrby(K key, K field, long amount) { - return createObservable(() -> commandBuilder.hincrby(key, field, amount)); + public Observable> hgetall(K key) { + return createObservable(() -> commandBuilder.hgetall(key)); } @Override - public Observable hincrbyfloat(K key, K field, double amount) { - return createObservable(() -> commandBuilder.hincrbyfloat(key, field, amount)); + public Observable hgetall(KeyValueStreamingChannel channel, K key) { + return createObservable(() -> commandBuilder.hgetall(channel, key)); } @Override - public Observable> hgetall(K key) { - return createObservable(() -> commandBuilder.hgetall(key)); + public Observable hincrby(K key, K field, long amount) { + return createObservable(() -> commandBuilder.hincrby(key, field, amount)); } @Override - public Observable hgetall(KeyValueStreamingChannel channel, K key) { - return createObservable(() -> commandBuilder.hgetall(channel, key)); + public Observable hincrbyfloat(K key, K field, double amount) { + return createObservable(() -> commandBuilder.hincrbyfloat(key, field, amount)); } @Override @@ -456,11 +741,6 @@ public Observable hlen(K key) { return createObservable(() -> commandBuilder.hlen(key)); } - @Override - public Observable hstrlen(K key, K field) { - return createObservable(() -> commandBuilder.hstrlen(key, field)); - } - @Override public Observable hmget(K key, K... fields) { return createDissolvingObservable(() -> commandBuilder.hmget(key, fields)); @@ -476,6 +756,47 @@ public Observable hmset(K key, Map map) { return createObservable(() -> commandBuilder.hmset(key, map)); } + @Override + public Observable> hscan(K key) { + return createObservable(() -> commandBuilder.hscan(key)); + } + + @Override + public Observable> hscan(K key, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.hscan(key, scanArgs)); + } + + @Override + public Observable> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.hscan(key, scanCursor, scanArgs)); + } + + @Override + public Observable> hscan(K key, ScanCursor scanCursor) { + return createObservable(() -> commandBuilder.hscan(key, scanCursor)); + } + + @Override + public Observable hscan(KeyValueStreamingChannel channel, K key) { + return createObservable(() -> commandBuilder.hscanStreaming(channel, key)); + } + + @Override + public Observable hscan(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.hscanStreaming(channel, key, scanArgs)); + } + + @Override + public Observable hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, + ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.hscanStreaming(channel, key, scanCursor, scanArgs)); + } + + @Override + public Observable hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor) { + return createObservable(() -> commandBuilder.hscanStreaming(channel, key, scanCursor)); + } + @Override public Observable hset(K key, K field, V value) { return createObservable(() -> commandBuilder.hset(key, field, value)); @@ -486,6 +807,11 @@ public Observable hsetnx(K key, K field, V value) { return createObservable(() -> commandBuilder.hsetnx(key, field, value)); } + @Override + public Observable hstrlen(K key, K field) { + return createObservable(() -> commandBuilder.hstrlen(key, field)); + } + @Override public Observable hvals(K key) { return createDissolvingObservable(() -> commandBuilder.hvals(key)); @@ -521,6 +847,11 @@ public Observable info(String section) { return createObservable(() -> commandBuilder.info(section)); } + @Override + public boolean isOpen() { + return connection.isOpen(); + } + @Override public Observable keys(K pattern) { return createDissolvingObservable(() -> commandBuilder.keys(pattern)); @@ -596,16 +927,6 @@ public Observable ltrim(K key, long start, long stop) { return createObservable(() -> commandBuilder.ltrim(key, start, stop)); } - @Override - public Observable migrate(String host, int port, K key, int db, long timeout) { - return createObservable(() -> commandBuilder.migrate(host, port, key, db, timeout)); - } - - @Override - public Observable migrate(String host, int port, int db, long timeout, MigrateArgs migrateArgs) { - return createObservable(() -> commandBuilder.migrate(host, port, db, timeout, migrateArgs)); - } - @Override public Observable mget(K... keys) { return createDissolvingObservable(() -> commandBuilder.mget(keys)); @@ -625,13 +946,18 @@ public Observable mget(ValueStreamingChannel channel, Iterable keys) } @Override - public Observable move(K key, int db) { - return createObservable(() -> commandBuilder.move(key, db)); + public Observable migrate(String host, int port, K key, int db, long timeout) { + return createObservable(() -> commandBuilder.migrate(host, port, key, db, timeout)); } @Override - public Observable multi() { - return createObservable(commandBuilder::multi); + public Observable migrate(String host, int port, int db, long timeout, MigrateArgs migrateArgs) { + return createObservable(() -> commandBuilder.migrate(host, port, db, timeout, migrateArgs)); + } + + @Override + public Observable move(K key, int db) { + return createObservable(() -> commandBuilder.move(key, db)); } @Override @@ -644,6 +970,11 @@ public Observable msetnx(Map map) { return createObservable(() -> commandBuilder.msetnx(map)); } + @Override + public Observable multi() { + return createObservable(commandBuilder::multi); + } + @Override public Observable objectEncoding(K key) { return createObservable(() -> commandBuilder.objectEncoding(key)); @@ -680,18 +1011,40 @@ public Observable pexpireat(K key, long timestamp) { } @Override - public Observable ping() { - return createObservable(commandBuilder::ping); + public Observable pfadd(K key, V... values) { + return createObservable(() -> commandBuilder.pfadd(key, values)); + } + + public Observable pfadd(K key, V value, V... values) { + return createObservable(() -> commandBuilder.pfadd(key, value, values)); } @Override - public Observable readOnly() { - return createObservable(commandBuilder::readOnly); + public Observable pfcount(K... keys) { + return createObservable(() -> commandBuilder.pfcount(keys)); + } + + public Observable pfcount(K key, K... keys) { + return createObservable(() -> commandBuilder.pfcount(key, keys)); } @Override - public Observable readWrite() { - return createObservable(commandBuilder::readWrite); + public Observable pfmerge(K destkey, K... sourcekeys) { + return createObservable(() -> commandBuilder.pfmerge(destkey, sourcekeys)); + } + + public Observable pfmerge(K destkey, K sourceKey, K... sourcekeys) { + return createObservable(() -> commandBuilder.pfmerge(destkey, sourceKey, sourcekeys)); + } + + @Override + public Observable ping() { + return createObservable(commandBuilder::ping); + } + + @Override + public Observable psetex(K key, long milliseconds, V value) { + return createObservable(() -> commandBuilder.psetex(key, milliseconds, value)); } @Override @@ -715,13 +1068,13 @@ public Observable pubsubChannels(K channel) { } @Override - public Observable> pubsubNumsub(K... channels) { - return createObservable(() -> commandBuilder.pubsubNumsub(channels)); + public Observable pubsubNumpat() { + return createObservable(commandBuilder::pubsubNumpat); } @Override - public Observable pubsubNumpat() { - return createObservable(commandBuilder::pubsubNumpat); + public Observable> pubsubNumsub(K... channels) { + return createObservable(() -> commandBuilder.pubsubNumsub(channels)); } @Override @@ -730,13 +1083,18 @@ public Observable quit() { } @Override - public Observable role() { - return createDissolvingObservable(commandBuilder::role); + public Observable randomkey() { + return createObservable(commandBuilder::randomkey); } @Override - public Observable randomkey() { - return createObservable(commandBuilder::randomkey); + public Observable readOnly() { + return createObservable(commandBuilder::readOnly); + } + + @Override + public Observable readWrite() { + return createObservable(commandBuilder::readWrite); } @Override @@ -749,11 +1107,21 @@ public Observable renamenx(K key, K newKey) { return createObservable(() -> commandBuilder.renamenx(key, newKey)); } + @Override + public void reset() { + getConnection().reset(); + } + @Override public Observable restore(K key, long ttl, byte[] value) { return createObservable(() -> commandBuilder.restore(key, ttl, value)); } + @Override + public Observable role() { + return createDissolvingObservable(commandBuilder::role); + } + @Override public Observable rpop(K key) { return createObservable(() -> commandBuilder.rpop(key)); @@ -789,6 +1157,46 @@ public Observable save() { return createObservable(commandBuilder::save); } + @Override + public Observable> scan() { + return createObservable(commandBuilder::scan); + } + + @Override + public Observable> scan(ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.scan(scanArgs)); + } + + @Override + public Observable> scan(ScanCursor scanCursor, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.scan(scanCursor, scanArgs)); + } + + @Override + public Observable> scan(ScanCursor scanCursor) { + return createObservable(() -> commandBuilder.scan(scanCursor)); + } + + @Override + public Observable scan(KeyStreamingChannel channel) { + return createObservable(() -> commandBuilder.scanStreaming(channel)); + } + + @Override + public Observable scan(KeyStreamingChannel channel, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.scanStreaming(channel, scanArgs)); + } + + @Override + public Observable scan(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.scanStreaming(channel, scanCursor, scanArgs)); + } + + @Override + public Observable scan(KeyStreamingChannel channel, ScanCursor scanCursor) { + return createObservable(() -> commandBuilder.scanStreaming(channel, scanCursor)); + } + @Override public Observable scard(K key) { return createObservable(() -> commandBuilder.scard(key)); @@ -833,10 +1241,6 @@ public Observable select(int db) { return createObservable(() -> commandBuilder.select(db)); } - public Observable swapdb(int db1, int db2) { - return createObservable(() -> commandBuilder.swapdb(db1, db2)); - } - @Override public Observable set(K key, V value) { return createObservable(() -> commandBuilder.set(key, value)); @@ -847,6 +1251,11 @@ public Observable set(K key, V value, SetArgs setArgs) { return createObservable(() -> commandBuilder.set(key, value, setArgs)); } + @Override + public void setTimeout(long timeout, TimeUnit unit) { + connection.setTimeout(timeout, unit); + } + @Override public Observable setbit(K key, long offset, int value) { return createObservable(() -> commandBuilder.setbit(key, offset, value)); @@ -857,11 +1266,6 @@ public Observable setex(K key, long seconds, V value) { return createObservable(() -> commandBuilder.setex(key, seconds, value)); } - @Override - public Observable psetex(K key, long milliseconds, V value) { - return createObservable(() -> commandBuilder.psetex(key, milliseconds, value)); - } - @Override public Observable setnx(K key, V value) { return createObservable(() -> commandBuilder.setnx(key, value)); @@ -897,11 +1301,6 @@ public Observable sismember(K key, V member) { return createObservable(() -> commandBuilder.sismember(key, member)); } - @Override - public Observable smove(K source, K destination, V member) { - return createObservable(() -> commandBuilder.smove(source, destination, member)); - } - @Override public Observable slaveof(String host, int port) { return createObservable(() -> commandBuilder.slaveof(host, port)); @@ -942,6 +1341,11 @@ public Observable smembers(ValueStreamingChannel channel, K key) { return createObservable(() -> commandBuilder.smembers(channel, key)); } + @Override + public Observable smove(K source, K destination, V member) { + return createObservable(() -> commandBuilder.smove(source, destination, member)); + } + @Override public Observable sort(K key) { return createDissolvingObservable(() -> commandBuilder.sort(key)); @@ -997,6 +1401,51 @@ public Observable srem(K key, V... members) { return createObservable(() -> commandBuilder.srem(key, members)); } + @Override + public Observable> sscan(K key) { + return createObservable(() -> commandBuilder.sscan(key)); + } + + @Override + public Observable> sscan(K key, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.sscan(key, scanArgs)); + } + + @Override + public Observable> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.sscan(key, scanCursor, scanArgs)); + } + + @Override + public Observable> sscan(K key, ScanCursor scanCursor) { + return createObservable(() -> commandBuilder.sscan(key, scanCursor)); + } + + @Override + public Observable sscan(ValueStreamingChannel channel, K key) { + return createObservable(() -> commandBuilder.sscanStreaming(channel, key)); + } + + @Override + public Observable sscan(ValueStreamingChannel channel, K key, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.sscanStreaming(channel, key, scanArgs)); + } + + @Override + public Observable sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs) { + return createObservable(() -> commandBuilder.sscanStreaming(channel, key, scanCursor, scanArgs)); + } + + @Override + public Observable sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor) { + return createObservable(() -> commandBuilder.sscanStreaming(channel, key, scanCursor)); + } + + @Override + public Observable strlen(K key) { + return createObservable(() -> commandBuilder.strlen(key)); + } + @Override public Observable sunion(K... keys) { return createDissolvingObservable(() -> commandBuilder.sunion(keys)); @@ -1012,14 +1461,18 @@ public Observable sunionstore(K destination, K... keys) { return createObservable(() -> commandBuilder.sunionstore(destination, keys)); } + public Observable swapdb(int db1, int db2) { + return createObservable(() -> commandBuilder.swapdb(db1, db2)); + } + @Override public Observable sync() { return createObservable(commandBuilder::sync); } @Override - public Observable strlen(K key) { - return createObservable(() -> commandBuilder.strlen(key)); + public Observable time() { + return createDissolvingObservable(commandBuilder::time); } @Override @@ -1042,8 +1495,12 @@ public Observable type(K key) { } @Override - public Observable watch(K... keys) { - return createObservable(() -> commandBuilder.watch(keys)); + public Observable unlink(K... keys) { + return createObservable(() -> commandBuilder.unlink(keys)); + } + + public Observable unlink(Iterable keys) { + return createObservable(() -> commandBuilder.unlink(keys)); } @Override @@ -1051,6 +1508,16 @@ public Observable unwatch() { return createObservable(commandBuilder::unwatch); } + @Override + public Observable waitForReplication(int replicas, long timeout) { + return createObservable(() -> commandBuilder.wait(replicas, timeout)); + } + + @Override + public Observable watch(K... keys) { + return createObservable(() -> commandBuilder.watch(keys)); + } + @Override public Observable zadd(K key, double score, V member) { return createObservable(() -> commandBuilder.zadd(key, null, score, member)); @@ -1127,83 +1594,83 @@ public Observable zinterstore(K destination, ZStoreArgs storeArgs, K... ke } @Override - public Observable zrange(K key, long start, long stop) { - return createDissolvingObservable(() -> commandBuilder.zrange(key, start, stop)); + public Observable zlexcount(K key, String min, String max) { + return createObservable(() -> commandBuilder.zlexcount(key, min, max)); } @Override - public Observable> zrangeWithScores(K key, long start, long stop) { - return createDissolvingObservable(() -> commandBuilder.zrangeWithScores(key, start, stop)); + public Observable zlexcount(K key, Range range) { + return createObservable(() -> commandBuilder.zlexcount(key, range)); } @Override - public Observable zrangebyscore(K key, double min, double max) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max)); + public Observable zrange(K key, long start, long stop) { + return createDissolvingObservable(() -> commandBuilder.zrange(key, start, stop)); } @Override - public Observable zrangebyscore(K key, String min, String max) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max)); + public Observable zrange(ValueStreamingChannel channel, K key, long start, long stop) { + return createObservable(() -> commandBuilder.zrange(channel, key, start, stop)); } @Override - public Observable zrangebyscore(K key, Range range) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, range, Limit.unlimited())); + public Observable> zrangeWithScores(K key, long start, long stop) { + return createDissolvingObservable(() -> commandBuilder.zrangeWithScores(key, start, stop)); } @Override - public Observable zrangebyscore(K key, double min, double max, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max, offset, count)); + public Observable zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { + return createObservable(() -> commandBuilder.zrangeWithScores(channel, key, start, stop)); } @Override - public Observable zrangebyscore(K key, String min, String max, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max, offset, count)); + public Observable zrangebylex(K key, String min, String max) { + return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, min, max)); } @Override - public Observable zrangebyscore(K key, Range range, Limit limit) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, range, limit)); + public Observable zrangebylex(K key, Range range) { + return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, range, Limit.unlimited())); } @Override - public Observable> zrangebyscoreWithScores(K key, double min, double max) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max)); + public Observable zrangebylex(K key, String min, String max, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, min, max, offset, count)); } @Override - public Observable> zrangebyscoreWithScores(K key, String min, String max) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max)); + public Observable zrangebylex(K key, Range range, Limit limit) { + return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, range, limit)); } @Override - public Observable> zrangebyscoreWithScores(K key, Range range) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, range, Limit.unlimited())); + public Observable zrangebyscore(K key, double min, double max) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max)); } @Override - public Observable> zrangebyscoreWithScores(K key, double min, double max, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); + public Observable zrangebyscore(K key, String min, String max) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max)); } @Override - public Observable> zrangebyscoreWithScores(K key, String min, String max, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); + public Observable zrangebyscore(K key, Range range) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, range, Limit.unlimited())); } @Override - public Observable> zrangebyscoreWithScores(K key, Range range, Limit limit) { - return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, range, limit)); + public Observable zrangebyscore(K key, double min, double max, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max, offset, count)); } @Override - public Observable zrange(ValueStreamingChannel channel, K key, long start, long stop) { - return createObservable(() -> commandBuilder.zrange(channel, key, start, stop)); + public Observable zrangebyscore(K key, String min, String max, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, min, max, offset, count)); } @Override - public Observable zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { - return createObservable(() -> commandBuilder.zrangeWithScores(channel, key, start, stop)); + public Observable zrangebyscore(K key, Range range, Limit limit) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscore(key, range, limit)); } @Override @@ -1239,48 +1706,88 @@ public Observable zrangebyscore(ValueStreamingChannel channel, K key, R } @Override - public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max) { - return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max)); + public Observable> zrangebyscoreWithScores(K key, double min, double max) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max)); } @Override - public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max) { - return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max)); + public Observable> zrangebyscoreWithScores(K key, String min, String max) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max)); } @Override - public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range) { - return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, range, Limit.unlimited())); + public Observable> zrangebyscoreWithScores(K key, Range range) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, range, Limit.unlimited())); } @Override - public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max, - long offset, long count) { - return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max, offset, count)); + public Observable> zrangebyscoreWithScores(K key, double min, double max, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); } @Override - public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max, - long offset, long count) { - return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max, offset, count)); + public Observable> zrangebyscoreWithScores(K key, String min, String max, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, min, max, offset, count)); } @Override - public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, - Limit limit) { - return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, range, limit)); + public Observable> zrangebyscoreWithScores(K key, Range range, Limit limit) { + return createDissolvingObservable(() -> commandBuilder.zrangebyscoreWithScores(key, range, limit)); } @Override - public Observable zrank(K key, V member) { - return createObservable(() -> commandBuilder.zrank(key, member)); - } + public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max) { + return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max)); + } + + @Override + public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max) { + return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max)); + } + + @Override + public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range) { + return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, range, Limit.unlimited())); + } + + @Override + public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max, + long offset, long count) { + return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max, offset, count)); + } + + @Override + public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max, + long offset, long count) { + return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, min, max, offset, count)); + } + + @Override + public Observable zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range, Limit limit) { + return createObservable(() -> commandBuilder.zrangebyscoreWithScores(channel, key, range, limit)); + } + + @Override + public Observable zrank(K key, V member) { + return createObservable(() -> commandBuilder.zrank(key, member)); + } @Override public Observable zrem(K key, V... members) { return createObservable(() -> commandBuilder.zrem(key, members)); } + @Override + public Observable zremrangebylex(K key, String min, String max) { + return createObservable(() -> commandBuilder.zremrangebylex(key, min, max)); + } + + @Override + public Observable zremrangebylex(K key, Range range) { + return createObservable(() -> commandBuilder.zremrangebylex(key, range)); + } + @Override public Observable zremrangebyrank(K key, long start, long stop) { return createObservable(() -> commandBuilder.zremrangebyrank(key, start, stop)); @@ -1306,11 +1813,21 @@ public Observable zrevrange(K key, long start, long stop) { return createDissolvingObservable(() -> commandBuilder.zrevrange(key, start, stop)); } + @Override + public Observable zrevrange(ValueStreamingChannel channel, K key, long start, long stop) { + return createObservable(() -> commandBuilder.zrevrange(channel, key, start, stop)); + } + @Override public Observable> zrevrangeWithScores(K key, long start, long stop) { return createDissolvingObservable(() -> commandBuilder.zrevrangeWithScores(key, start, stop)); } + @Override + public Observable zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { + return createObservable(() -> commandBuilder.zrevrangeWithScores(channel, key, start, stop)); + } + @Override public Observable zrevrangebylex(K key, Range range) { return createDissolvingObservable(() -> commandBuilder.zrevrangebylex(key, range, Limit.unlimited())); @@ -1351,46 +1868,6 @@ public Observable zrevrangebyscore(K key, Range range, Limi return createDissolvingObservable(() -> commandBuilder.zrevrangebyscore(key, range, limit)); } - @Override - public Observable> zrevrangebyscoreWithScores(K key, double max, double min) { - return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min)); - } - - @Override - public Observable> zrevrangebyscoreWithScores(K key, String max, String min) { - return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min)); - } - - @Override - public Observable> zrevrangebyscoreWithScores(K key, Range range) { - return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, range, Limit.unlimited())); - } - - @Override - public Observable> zrevrangebyscoreWithScores(K key, double max, double min, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); - } - - @Override - public Observable> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); - } - - @Override - public Observable> zrevrangebyscoreWithScores(K key, Range range, Limit limit) { - return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, range, limit)); - } - - @Override - public Observable zrevrange(ValueStreamingChannel channel, K key, long start, long stop) { - return createObservable(() -> commandBuilder.zrevrange(channel, key, start, stop)); - } - - @Override - public Observable zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { - return createObservable(() -> commandBuilder.zrevrangeWithScores(channel, key, start, stop)); - } - @Override public Observable zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min) { return createObservable(() -> commandBuilder.zrevrangebyscore(channel, key, max, min)); @@ -1424,177 +1901,72 @@ public Observable zrevrangebyscore(ValueStreamingChannel channel, K key } @Override - public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min) { - return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min)); - } - - @Override - public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min) { - return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min)); - } - - @Override - public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range) { - return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, range, Limit.unlimited())); - } - - @Override - public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min, - long offset, long count) { - return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min, offset, count)); - } - - @Override - public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min, - long offset, long count) { - return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min, offset, count)); - } - - @Override - public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, - Limit limit) { - return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, range, limit)); - } - - @Override - public Observable zrevrank(K key, V member) { - return createObservable(() -> commandBuilder.zrevrank(key, member)); - } - - @Override - public Observable zscore(K key, V member) { - return createObservable(() -> commandBuilder.zscore(key, member)); - } - - @Override - public Observable zunionstore(K destination, K... keys) { - return createObservable(() -> commandBuilder.zunionstore(destination, keys)); - } - - @Override - public Observable zunionstore(K destination, ZStoreArgs storeArgs, K... keys) { - return createObservable(() -> commandBuilder.zunionstore(destination, storeArgs, keys)); - } - - @Override - public Observable> scan() { - return createObservable(commandBuilder::scan); - } - - @Override - public Observable> scan(ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.scan(scanArgs)); - } - - @Override - public Observable> scan(ScanCursor scanCursor, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.scan(scanCursor, scanArgs)); - } - - @Override - public Observable> scan(ScanCursor scanCursor) { - return createObservable(() -> commandBuilder.scan(scanCursor)); - } - - @Override - public Observable scan(KeyStreamingChannel channel) { - return createObservable(() -> commandBuilder.scanStreaming(channel)); - } - - @Override - public Observable scan(KeyStreamingChannel channel, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.scanStreaming(channel, scanArgs)); - } - - @Override - public Observable scan(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.scanStreaming(channel, scanCursor, scanArgs)); - } - - @Override - public Observable scan(KeyStreamingChannel channel, ScanCursor scanCursor) { - return createObservable(() -> commandBuilder.scanStreaming(channel, scanCursor)); - } - - @Override - public Observable> sscan(K key) { - return createObservable(() -> commandBuilder.sscan(key)); - } - - @Override - public Observable> sscan(K key, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.sscan(key, scanArgs)); - } - - @Override - public Observable> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.sscan(key, scanCursor, scanArgs)); - } - - @Override - public Observable> sscan(K key, ScanCursor scanCursor) { - return createObservable(() -> commandBuilder.sscan(key, scanCursor)); + public Observable> zrevrangebyscoreWithScores(K key, double max, double min) { + return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min)); } @Override - public Observable sscan(ValueStreamingChannel channel, K key) { - return createObservable(() -> commandBuilder.sscanStreaming(channel, key)); + public Observable> zrevrangebyscoreWithScores(K key, String max, String min) { + return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min)); } @Override - public Observable sscan(ValueStreamingChannel channel, K key, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.sscanStreaming(channel, key, scanArgs)); + public Observable> zrevrangebyscoreWithScores(K key, Range range) { + return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, range, Limit.unlimited())); } @Override - public Observable sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.sscanStreaming(channel, key, scanCursor, scanArgs)); + public Observable> zrevrangebyscoreWithScores(K key, double max, double min, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); } @Override - public Observable sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor) { - return createObservable(() -> commandBuilder.sscanStreaming(channel, key, scanCursor)); + public Observable> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count) { + return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, max, min, offset, count)); } @Override - public Observable> hscan(K key) { - return createObservable(() -> commandBuilder.hscan(key)); + public Observable> zrevrangebyscoreWithScores(K key, Range range, Limit limit) { + return createDissolvingObservable(() -> commandBuilder.zrevrangebyscoreWithScores(key, range, limit)); } @Override - public Observable> hscan(K key, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.hscan(key, scanArgs)); + public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min) { + return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min)); } @Override - public Observable> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.hscan(key, scanCursor, scanArgs)); + public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min) { + return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min)); } @Override - public Observable> hscan(K key, ScanCursor scanCursor) { - return createObservable(() -> commandBuilder.hscan(key, scanCursor)); + public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range) { + return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, range, Limit.unlimited())); } @Override - public Observable hscan(KeyValueStreamingChannel channel, K key) { - return createObservable(() -> commandBuilder.hscanStreaming(channel, key)); + public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min, + long offset, long count) { + return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min, offset, count)); } @Override - public Observable hscan(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.hscanStreaming(channel, key, scanArgs)); + public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min, + long offset, long count) { + return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, max, min, offset, count)); } @Override - public Observable hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, - ScanArgs scanArgs) { - return createObservable(() -> commandBuilder.hscanStreaming(channel, key, scanCursor, scanArgs)); + public Observable zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Range range, Limit limit) { + return createObservable(() -> commandBuilder.zrevrangebyscoreWithScores(channel, key, range, limit)); } @Override - public Observable hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor) { - return createObservable(() -> commandBuilder.hscanStreaming(channel, key, scanCursor)); + public Observable zrevrank(K key, V member) { + return createObservable(() -> commandBuilder.zrevrank(key, member)); } @Override @@ -1639,390 +2011,17 @@ public Observable zscan(ScoredValueStreamingChannel channel } @Override - public String digest(V script) { - return LettuceStrings.digest(codec.encodeValue(script)); + public Observable zscore(K key, V member) { + return createObservable(() -> commandBuilder.zscore(key, member)); } @Override - public Observable time() { - return createDissolvingObservable(commandBuilder::time); - } - - @Override - public Observable waitForReplication(int replicas, long timeout) { - return createObservable(() -> commandBuilder.wait(replicas, timeout)); - } - - @Override - public Observable pfadd(K key, V... values) { - return createObservable(() -> commandBuilder.pfadd(key, values)); - } - - public Observable pfadd(K key, V value, V... values) { - return createObservable(() -> commandBuilder.pfadd(key, value, values)); - } - - @Override - public Observable pfmerge(K destkey, K... sourcekeys) { - return createObservable(() -> commandBuilder.pfmerge(destkey, sourcekeys)); - } - - public Observable pfmerge(K destkey, K sourceKey, K... sourcekeys) { - return createObservable(() -> commandBuilder.pfmerge(destkey, sourceKey, sourcekeys)); - } - - @Override - public Observable pfcount(K... keys) { - return createObservable(() -> commandBuilder.pfcount(keys)); - } - - public Observable pfcount(K key, K... keys) { - return createObservable(() -> commandBuilder.pfcount(key, keys)); - } - - @Override - public Observable clusterBumpepoch() { - return createObservable(() -> commandBuilder.clusterBumpepoch()); - } - - @Override - public Observable clusterMeet(String ip, int port) { - return createObservable(() -> commandBuilder.clusterMeet(ip, port)); - } - - @Override - public Observable clusterForget(String nodeId) { - return createObservable(() -> commandBuilder.clusterForget(nodeId)); - } - - @Override - public Observable clusterAddSlots(int... slots) { - return createObservable(() -> commandBuilder.clusterAddslots(slots)); - } - - @Override - public Observable clusterDelSlots(int... slots) { - return createObservable(() -> commandBuilder.clusterDelslots(slots)); - } - - @Override - public Observable clusterInfo() { - return createObservable(commandBuilder::clusterInfo); - } - - @Override - public Observable clusterMyId() { - return createObservable(commandBuilder::clusterMyId); - } - - @Override - public Observable clusterNodes() { - return createObservable(commandBuilder::clusterNodes); - } - - @Override - public Observable clusterGetKeysInSlot(int slot, int count) { - return createDissolvingObservable(() -> commandBuilder.clusterGetKeysInSlot(slot, count)); - } - - @Override - public Observable clusterCountKeysInSlot(int slot) { - return createObservable(() -> commandBuilder.clusterCountKeysInSlot(slot)); - } - - @Override - public Observable clusterCountFailureReports(String nodeId) { - return createObservable(() -> commandBuilder.clusterCountFailureReports(nodeId)); - } - - @Override - public Observable clusterKeyslot(K key) { - return createObservable(() -> commandBuilder.clusterKeyslot(key)); - } - - @Override - public Observable clusterSaveconfig() { - return createObservable(() -> commandBuilder.clusterSaveconfig()); - } - - @Override - public Observable clusterSetConfigEpoch(long configEpoch) { - return createObservable(() -> commandBuilder.clusterSetConfigEpoch(configEpoch)); - } - - @Override - public Observable clusterSlots() { - return createDissolvingObservable(commandBuilder::clusterSlots); - } - - @Override - public Observable clusterSetSlotNode(int slot, String nodeId) { - return createObservable(() -> commandBuilder.clusterSetSlotNode(slot, nodeId)); - } - - @Override - public Observable clusterSetSlotStable(int slot) { - return createObservable(() -> commandBuilder.clusterSetSlotStable(slot)); - } - - @Override - public Observable clusterSetSlotMigrating(int slot, String nodeId) { - return createObservable(() -> commandBuilder.clusterSetSlotMigrating(slot, nodeId)); - } - - @Override - public Observable clusterSetSlotImporting(int slot, String nodeId) { - return createObservable(() -> commandBuilder.clusterSetSlotImporting(slot, nodeId)); - } - - @Override - public Observable clusterFailover(boolean force) { - return createObservable(() -> commandBuilder.clusterFailover(force)); - } - - @Override - public Observable clusterReset(boolean hard) { - return createObservable(() -> commandBuilder.clusterReset(hard)); - } - - @Override - public Observable asking() { - return createObservable(commandBuilder::asking); - } - - @Override - public Observable clusterReplicate(String nodeId) { - return createObservable(() -> commandBuilder.clusterReplicate(nodeId)); - } - - @Override - public Observable clusterFlushslots() { - return createObservable(commandBuilder::clusterFlushslots); - } - - @Override - public Observable clusterSlaves(String nodeId) { - return createDissolvingObservable(() -> commandBuilder.clusterSlaves(nodeId)); - } - - @Override - public Observable zlexcount(K key, String min, String max) { - return createObservable(() -> commandBuilder.zlexcount(key, min, max)); - } - - @Override - public Observable zlexcount(K key, Range range) { - return createObservable(() -> commandBuilder.zlexcount(key, range)); - } - - @Override - public Observable zremrangebylex(K key, String min, String max) { - return createObservable(() -> commandBuilder.zremrangebylex(key, min, max)); - } - - @Override - public Observable zremrangebylex(K key, Range range) { - return createObservable(() -> commandBuilder.zremrangebylex(key, range)); - } - - @Override - public Observable zrangebylex(K key, String min, String max) { - return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, min, max)); - } - - @Override - public Observable zrangebylex(K key, Range range) { - return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, range, Limit.unlimited())); - } - - @Override - public Observable zrangebylex(K key, String min, String max, long offset, long count) { - return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, min, max, offset, count)); - } - - @Override - public Observable zrangebylex(K key, Range range, Limit limit) { - return createDissolvingObservable(() -> commandBuilder.zrangebylex(key, range, limit)); - } - - @Override - public Observable geoadd(K key, double longitude, double latitude, V member) { - return createObservable(() -> commandBuilder.geoadd(key, longitude, latitude, member)); - } - - @Override - public Observable geoadd(K key, Object... lngLatMember) { - return createDissolvingObservable(() -> commandBuilder.geoadd(key, lngLatMember)); - } - - @Override - public Observable geohash(K key, V... members) { - return createDissolvingObservable(() -> commandBuilder.geohash(key, members)); - } - - @Override - public Observable georadius(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { - return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, - unit.name())); - } - - protected Observable georadius_ro(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit) { - return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, - unit.name())); - } - - @Override - public Observable> georadius(K key, double longitude, double latitude, double distance, GeoArgs.Unit unit, - GeoArgs geoArgs) { - return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS, key, longitude, latitude, distance, - unit.name(), geoArgs)); - } - - protected Observable> georadius_ro(K key, double longitude, double latitude, double distance, - GeoArgs.Unit unit, GeoArgs geoArgs) { - return createDissolvingObservable(() -> commandBuilder.georadius(GEORADIUS_RO, key, longitude, latitude, distance, - unit.name(), - geoArgs)); - } - - @Override - public Observable georadius(K key, double longitude, double latitude, double distance, Unit unit, - GeoRadiusStoreArgs geoRadiusStoreArgs) { - return createDissolvingObservable( - () -> commandBuilder.georadius(key, longitude, latitude, distance, unit.name(), geoRadiusStoreArgs)); - } - - @Override - public Observable georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit) { - return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, - unit.name())); - } - - protected Observable georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit) { - return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, - unit.name())); - } - - @Override - public Observable> georadiusbymember(K key, V member, double distance, GeoArgs.Unit unit, GeoArgs geoArgs) { - return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER, key, member, distance, - unit.name(), geoArgs)); - } - - protected Observable> georadiusbymember_ro(K key, V member, double distance, GeoArgs.Unit unit, GeoArgs geoArgs) { - return createDissolvingObservable(() -> commandBuilder.georadiusbymember(GEORADIUSBYMEMBER_RO, key, member, distance, - unit.name(), geoArgs)); - } - - @Override - public Observable georadiusbymember(K key, V member, double distance, Unit unit, - GeoRadiusStoreArgs geoRadiusStoreArgs) { - return createDissolvingObservable( - () -> commandBuilder.georadiusbymember(key, member, distance, unit.name(), geoRadiusStoreArgs)); - } - - @Override - public Observable geopos(K key, V... members) { - return createDissolvingObservable(() -> commandBuilder.geopos(key, members)); - } - - @Override - public Observable geodist(K key, V from, V to, GeoArgs.Unit unit) { - return createDissolvingObservable(() -> commandBuilder.geodist(key, from, to, unit)); - } - - @Override - public Observable dispatch(ProtocolKeyword type, CommandOutput output) { - - LettuceAssert.notNull(type, "Command type must not be null"); - LettuceAssert.notNull(output, "CommandOutput type must not be null"); - - return createDissolvingObservable(() -> new Command<>(type, output)); - } - - @Override - public Observable 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 createDissolvingObservable(() -> new Command<>(type, output, args)); - } - - protected Observable createObservable(CommandType type, CommandOutput output, CommandArgs args) { - return createObservable(() -> new Command<>(type, output, args)); - } - - public Observable createObservable(Supplier> commandSupplier) { - return Observable.create(new ReactiveCommandDispatcher<>(commandSupplier, connection, false)); - } - - @SuppressWarnings("unchecked") - public R createDissolvingObservable(Supplier> commandSupplier) { - return (R) Observable.create(new ReactiveCommandDispatcher<>(commandSupplier, connection, true)); - } - - @SuppressWarnings("unchecked") - public R createDissolvingObservable(CommandType type, CommandOutput output, CommandArgs args) { - return (R) Observable - .create(new ReactiveCommandDispatcher<>(() -> new Command<>(type, output, args), - connection, true)); - } - - /** - * Emits just {@link Success#Success} or the {@link Throwable} after the inner observable is completed. - * - * @param observable inner observable - * @param used for type inference - * @return Success observable - */ - protected Observable getSuccessObservable(final Observable observable) { - return Observable.create(new Observable.OnSubscribe() { - @Override - public void call(Subscriber subscriber) { - - observable.subscribe(new Subscriber() { - @Override - public void onCompleted() { - subscriber.onNext(Success.Success); - subscriber.onCompleted(); - } - - @Override - public void onError(Throwable throwable) { - subscriber.onError(throwable); - } - - @Override - public void onNext(Object k) { - - } - }); - } - }); - } - - public void setTimeout(long timeout, TimeUnit unit) { - connection.setTimeout(timeout, unit); - } - - @Override - public void close() { - connection.close(); - } - - @Override - public boolean isOpen() { - return connection.isOpen(); + public Observable zunionstore(K destination, K... keys) { + return createObservable(() -> commandBuilder.zunionstore(destination, keys)); } @Override - public void reset() { - getConnection().reset(); - } - - public StatefulConnection getConnection() { - return connection; + public Observable zunionstore(K destination, ZStoreArgs storeArgs, K... keys) { + return createObservable(() -> commandBuilder.zunionstore(destination, storeArgs, keys)); } } diff --git a/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java b/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java index 76ff7480c7..b5f6a299f8 100644 --- a/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java +++ b/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java @@ -36,197 +36,372 @@ * @param * @author Mark Paluch */ -@SuppressWarnings({ "unchecked", "Convert2Diamond", "WeakerAccess", "varargs" }) +@SuppressWarnings({ "unchecked", "varargs" }) class RedisCommandBuilder extends BaseRedisCommandBuilder { - static final String MUST_NOT_CONTAIN_NULL_ELEMENTS = "must not contain null elements"; - static final String MUST_NOT_BE_EMPTY = "must not be empty"; - static final String MUST_NOT_BE_NULL = "must not be null"; + private static final String MUST_NOT_CONTAIN_NULL_ELEMENTS = "must not contain null elements"; + private static final String MUST_NOT_BE_EMPTY = "must not be empty"; + private static final String MUST_NOT_BE_NULL = "must not be null"; private static final byte[] MINUS_BYTES = { '-' }; private static final byte[] PLUS_BYTES = { '+' }; private final RedisCodec STRING_CODEC = new Utf8StringCodec(); - public RedisCommandBuilder(RedisCodec codec) { + RedisCommandBuilder(RedisCodec codec) { super(codec); } - public Command append(K key, V value) { + Command append(K key, V value) { notNullKey(key); - return createCommand(APPEND, new IntegerOutput(codec), key, value); + return createCommand(APPEND, new IntegerOutput<>(codec), key, value); } - public Command auth(String password) { + Command asking() { + + CommandArgs args = new CommandArgs<>(codec); + return createCommand(ASKING, new StatusOutput<>(codec), args); + } + + Command auth(String password) { LettuceAssert.notNull(password, "Password " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(password, "Password " + MUST_NOT_BE_EMPTY); return auth(password.toCharArray()); } - public Command auth(char[] password) { + Command auth(char[] password) { LettuceAssert.notNull(password, "Password " + MUST_NOT_BE_NULL); LettuceAssert.isTrue(password.length > 0, "Password " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).add(password); - return createCommand(AUTH, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(password); + return createCommand(AUTH, new StatusOutput<>(codec), args); } - public Command bgrewriteaof() { - return createCommand(BGREWRITEAOF, new StatusOutput(codec)); + Command bgrewriteaof() { + return createCommand(BGREWRITEAOF, new StatusOutput<>(codec)); } - public Command bgsave() { - return createCommand(BGSAVE, new StatusOutput(codec)); + Command bgsave() { + return createCommand(BGSAVE, new StatusOutput<>(codec)); } - public Command bitcount(K key) { + Command bitcount(K key) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key); - return createCommand(BITCOUNT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key); + return createCommand(BITCOUNT, new IntegerOutput<>(codec), args); } - public Command bitcount(K key, long start, long end) { + Command bitcount(K key, long start, long end) { notNullKey(key); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(start).add(end); - return createCommand(BITCOUNT, new IntegerOutput(codec), args); + return createCommand(BITCOUNT, new IntegerOutput<>(codec), args); } - public Command> bitfield(K key, BitFieldArgs bitFieldArgs) { + Command> bitfield(K key, BitFieldArgs bitFieldArgs) { notNullKey(key); LettuceAssert.notNull(bitFieldArgs, "BitFieldArgs must not be null"); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key); bitFieldArgs.build(args); - return createCommand(BITFIELD, (CommandOutput) new ArrayOutput(codec), args); - } - - public Command bitpos(K key, boolean state) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(state ? 1 : 0); - return createCommand(BITPOS, new IntegerOutput(codec), args); - } - - public Command bitpos(K key, boolean state, long start, long end) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(state ? 1 : 0).add(start).add(end); - return createCommand(BITPOS, new IntegerOutput(codec), args); + return createCommand(BITFIELD, (CommandOutput) new ArrayOutput<>(codec), args); } - public Command bitopAnd(K destination, K... keys) { + Command bitopAnd(K destination, K... keys) { LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); notEmpty(keys); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(AND).addKey(destination).addKeys(keys); - return createCommand(BITOP, new IntegerOutput(codec), args); + return createCommand(BITOP, new IntegerOutput<>(codec), args); } - public Command bitopNot(K destination, K source) { + Command bitopNot(K destination, K source) { LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); LettuceAssert.notNull(source, "Source " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(NOT).addKey(destination).addKey(source); - return createCommand(BITOP, new IntegerOutput(codec), args); + return createCommand(BITOP, new IntegerOutput<>(codec), args); } - public Command bitopOr(K destination, K... keys) { + Command bitopOr(K destination, K... keys) { LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); notEmpty(keys); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(OR).addKey(destination).addKeys(keys); - return createCommand(BITOP, new IntegerOutput(codec), args); + return createCommand(BITOP, new IntegerOutput<>(codec), args); } - public Command bitopXor(K destination, K... keys) { + Command bitopXor(K destination, K... keys) { LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); notEmpty(keys); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(XOR).addKey(destination).addKeys(keys); - return createCommand(BITOP, new IntegerOutput(codec), args); + return createCommand(BITOP, new IntegerOutput<>(codec), args); + } + + Command bitpos(K key, boolean state) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(state ? 1 : 0); + return createCommand(BITPOS, new IntegerOutput<>(codec), args); + } + + Command bitpos(K key, boolean state, long start, long end) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(state ? 1 : 0).add(start).add(end); + return createCommand(BITPOS, new IntegerOutput<>(codec), args); } - public Command> blpop(long timeout, K... keys) { + Command> blpop(long timeout, K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys).add(timeout); - return createCommand(BLPOP, new KeyValueOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys).add(timeout); + return createCommand(BLPOP, new KeyValueOutput<>(codec), args); } - public Command> brpop(long timeout, K... keys) { + Command> brpop(long timeout, K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys).add(timeout); - return createCommand(BRPOP, new KeyValueOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys).add(timeout); + return createCommand(BRPOP, new KeyValueOutput<>(codec), args); } - public Command brpoplpush(long timeout, K source, K destination) { + Command brpoplpush(long timeout, K source, K destination) { LettuceAssert.notNull(source, "Source " + MUST_NOT_BE_NULL); LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(source).addKey(destination).add(timeout); - return createCommand(BRPOPLPUSH, new ValueOutput(codec), args); - } - - public Command clientGetname() { - CommandArgs args = new CommandArgs(codec).add(GETNAME); - return createCommand(CLIENT, new KeyOutput(codec), args); + return createCommand(BRPOPLPUSH, new ValueOutput<>(codec), args); } - public Command clientSetname(K name) { - LettuceAssert.notNull(name, "Name " + MUST_NOT_BE_NULL); - - CommandArgs args = new CommandArgs(codec).add(SETNAME).addKey(name); - return createCommand(CLIENT, new StatusOutput(codec), args); + Command clientGetname() { + CommandArgs args = new CommandArgs<>(codec).add(GETNAME); + return createCommand(CLIENT, new KeyOutput<>(codec), args); } - public Command clientKill(String addr) { + Command clientKill(String addr) { LettuceAssert.notNull(addr, "Addr " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(addr, "Addr " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).add(KILL).add(addr); - return createCommand(CLIENT, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(KILL).add(addr); + return createCommand(CLIENT, new StatusOutput<>(codec), args); } - public Command clientKill(KillArgs killArgs) { + Command clientKill(KillArgs killArgs) { LettuceAssert.notNull(killArgs, "KillArgs " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).add(KILL); + CommandArgs args = new CommandArgs<>(codec).add(KILL); killArgs.build(args); - return createCommand(CLIENT, new IntegerOutput(codec), args); + return createCommand(CLIENT, new IntegerOutput<>(codec), args); + } + + Command clientList() { + CommandArgs args = new CommandArgs<>(codec).add(LIST); + return createCommand(CLIENT, new StatusOutput<>(codec), args); + } + + Command clientPause(long timeout) { + CommandArgs args = new CommandArgs<>(codec).add(PAUSE).add(timeout); + return createCommand(CLIENT, new StatusOutput<>(codec), args); + } + + Command clientSetname(K name) { + LettuceAssert.notNull(name, "Name " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).add(SETNAME).addKey(name); + return createCommand(CLIENT, new StatusOutput<>(codec), args); + } + + Command clusterAddslots(int[] slots) { + notEmptySlots(slots); + + CommandArgs args = new CommandArgs<>(codec).add(ADDSLOTS); + + for (int slot : slots) { + args.add(slot); + } + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterBumpepoch() { + CommandArgs args = new CommandArgs<>(codec).add(BUMPEPOCH); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterCountFailureReports(String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add("COUNT-FAILURE-REPORTS").add(nodeId); + return createCommand(CLUSTER, new IntegerOutput<>(codec), args); + } + + Command clusterCountKeysInSlot(int slot) { + CommandArgs args = new CommandArgs<>(codec).add(COUNTKEYSINSLOT).add(slot); + return createCommand(CLUSTER, new IntegerOutput<>(codec), args); + } + + Command clusterDelslots(int[] slots) { + notEmptySlots(slots); + + CommandArgs args = new CommandArgs<>(codec).add(DELSLOTS); + + for (int slot : slots) { + args.add(slot); + } + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterFailover(boolean force) { + + CommandArgs args = new CommandArgs<>(codec).add(FAILOVER); + if (force) { + args.add(FORCE); + } + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterFlushslots() { + + CommandArgs args = new CommandArgs<>(codec).add(FLUSHSLOTS); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterForget(String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add(FORGET).add(nodeId); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command> clusterGetKeysInSlot(int slot, int count) { + CommandArgs args = new CommandArgs<>(codec).add(GETKEYSINSLOT).add(slot).add(count); + return createCommand(CLUSTER, new KeyListOutput<>(codec), args); + } + + Command clusterInfo() { + CommandArgs args = new CommandArgs<>(codec).add(INFO); + + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterKeyslot(K key) { + CommandArgs args = new CommandArgs<>(codec).add(KEYSLOT).addKey(key); + return createCommand(CLUSTER, new IntegerOutput<>(codec), args); + } + + Command clusterMeet(String ip, int port) { + LettuceAssert.notNull(ip, "IP " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(ip, "IP " + MUST_NOT_BE_EMPTY); + + CommandArgs args = new CommandArgs<>(codec).add(MEET).add(ip).add(port); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterMyId() { + CommandArgs args = new CommandArgs<>(codec).add(MYID); + + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterNodes() { + CommandArgs args = new CommandArgs<>(codec).add(NODES); + + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterReplicate(String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add(REPLICATE).add(nodeId); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterReset(boolean hard) { + + CommandArgs args = new CommandArgs<>(codec).add(RESET); + if (hard) { + args.add(HARD); + } else { + args.add(SOFT); + } + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterSaveconfig() { + CommandArgs args = new CommandArgs<>(codec).add(SAVECONFIG); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterSetConfigEpoch(long configEpoch) { + CommandArgs args = new CommandArgs<>(codec).add("SET-CONFIG-EPOCH").add(configEpoch); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterSetSlotImporting(int slot, String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add(SETSLOT).add(slot).add(IMPORTING).add(nodeId); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterSetSlotMigrating(int slot, String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add(SETSLOT).add(slot).add(MIGRATING).add(nodeId); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterSetSlotNode(int slot, String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add(SETSLOT).add(slot).add(NODE).add(nodeId); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); + } + + Command clusterSetSlotStable(int slot) { + + CommandArgs args = new CommandArgs<>(codec).add(SETSLOT).add(slot).add(STABLE); + return createCommand(CLUSTER, new StatusOutput<>(codec), args); } - public Command clientPause(long timeout) { - CommandArgs args = new CommandArgs(codec).add(PAUSE).add(timeout); - return createCommand(CLIENT, new StatusOutput(codec), args); + Command> clusterSlaves(String nodeId) { + assertNodeId(nodeId); + + CommandArgs args = new CommandArgs<>(codec).add(SLAVES).add(nodeId); + return createCommand(CLUSTER, new StringListOutput<>(codec), args); } - public Command clientList() { - CommandArgs args = new CommandArgs(codec).add(LIST); - return createCommand(CLIENT, new StatusOutput(codec), args); + Command> clusterSlots() { + CommandArgs args = new CommandArgs<>(codec).add(SLOTS); + return createCommand(CLUSTER, new ArrayOutput<>(codec), args); } - public Command> command() { + Command> command() { CommandArgs args = new CommandArgs((RedisCodec) STRING_CODEC); return createCommand(COMMAND, new ArrayOutput((RedisCodec) STRING_CODEC), args); } - public Command> commandInfo(String... commands) { + Command commandCount() { + CommandArgs args = new CommandArgs<>(codec).add(COUNT); + return createCommand(COMMAND, new IntegerOutput<>(codec), args); + } + + Command> commandInfo(String... commands) { LettuceAssert.notNull(commands, "Commands " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(commands, "Commands " + MUST_NOT_BE_EMPTY); LettuceAssert.noNullElements(commands, "Commands " + MUST_NOT_CONTAIN_NULL_ELEMENTS); @@ -241,553 +416,771 @@ public Command> commandInfo(String... commands) { return createCommand(COMMAND, new ArrayOutput((RedisCodec) STRING_CODEC), args); } - public Command commandCount() { - CommandArgs args = new CommandArgs(codec).add(COUNT); - return createCommand(COMMAND, new IntegerOutput(codec), args); - } - - public Command configRewrite() { - CommandArgs args = new CommandArgs(codec).add(REWRITE); - return createCommand(CONFIG, new StatusOutput(codec), args); - } - - public Command> configGet(String parameter) { + Command> configGet(String parameter) { LettuceAssert.notNull(parameter, "Parameter " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(parameter, "Parameter " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).add(GET).add(parameter); - return createCommand(CONFIG, new StringListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(GET).add(parameter); + return createCommand(CONFIG, new StringListOutput<>(codec), args); + } + + Command configResetstat() { + CommandArgs args = new CommandArgs<>(codec).add(RESETSTAT); + return createCommand(CONFIG, new StatusOutput<>(codec), args); } - public Command configResetstat() { - CommandArgs args = new CommandArgs(codec).add(RESETSTAT); - return createCommand(CONFIG, new StatusOutput(codec), args); + Command configRewrite() { + CommandArgs args = new CommandArgs<>(codec).add(REWRITE); + return createCommand(CONFIG, new StatusOutput<>(codec), args); } - public Command configSet(String parameter, String value) { + Command configSet(String parameter, String value) { LettuceAssert.notNull(parameter, "Parameter " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(parameter, "Parameter " + MUST_NOT_BE_EMPTY); LettuceAssert.notNull(value, "Value " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).add(SET).add(parameter).add(value); - return createCommand(CONFIG, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(SET).add(parameter).add(value); + return createCommand(CONFIG, new StatusOutput<>(codec), args); } - public Command dbsize() { - return createCommand(DBSIZE, new IntegerOutput(codec)); + Command dbsize() { + return createCommand(DBSIZE, new IntegerOutput<>(codec)); } - public Command debugCrashAndRecover(Long delay) { - CommandArgs args = new CommandArgs(codec).add("CRASH-AND-RECOVER"); + Command debugCrashAndRecover(Long delay) { + CommandArgs args = new CommandArgs<>(codec).add("CRASH-AND-RECOVER"); if (delay != null) { args.add(delay); } - return createCommand(DEBUG, new StatusOutput(codec), args); + return createCommand(DEBUG, new StatusOutput<>(codec), args); } - public Command debugObject(K key) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec).add(OBJECT).addKey(key); - return createCommand(DEBUG, new StatusOutput(codec), args); + Command debugHtstats(int db) { + CommandArgs args = new CommandArgs<>(codec).add(HTSTATS).add(db); + return createCommand(DEBUG, new StatusOutput<>(codec), args); } - public Command debugOom() { - return createCommand(DEBUG, null, new CommandArgs(codec).add("OOM")); + Command debugObject(K key) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).add(OBJECT).addKey(key); + return createCommand(DEBUG, new StatusOutput<>(codec), args); } - public Command debugHtstats(int db) { - CommandArgs args = new CommandArgs(codec).add(HTSTATS).add(db); - return createCommand(DEBUG, new StatusOutput(codec), args); + Command debugOom() { + return createCommand(DEBUG, null, new CommandArgs<>(codec).add("OOM")); } - public Command debugReload() { - return createCommand(DEBUG, new StatusOutput(codec), new CommandArgs(codec).add(RELOAD)); + Command debugReload() { + return createCommand(DEBUG, new StatusOutput<>(codec), new CommandArgs<>(codec).add(RELOAD)); } - public Command debugRestart(Long delay) { - CommandArgs args = new CommandArgs(codec).add(RESTART); + Command debugRestart(Long delay) { + CommandArgs args = new CommandArgs<>(codec).add(RESTART); if (delay != null) { args.add(delay); } - return createCommand(DEBUG, new StatusOutput(codec), args); + return createCommand(DEBUG, new StatusOutput<>(codec), args); } - public Command debugSdslen(K key) { + Command debugSdslen(K key) { notNullKey(key); - return createCommand(DEBUG, new StatusOutput(codec), new CommandArgs(codec).add("SDSLEN").addKey(key)); + return createCommand(DEBUG, new StatusOutput<>(codec), new CommandArgs<>(codec).add("SDSLEN").addKey(key)); } - public Command debugSegfault() { - CommandArgs args = new CommandArgs(codec).add(SEGFAULT); + Command debugSegfault() { + CommandArgs args = new CommandArgs<>(codec).add(SEGFAULT); return createCommand(DEBUG, null, args); } - public Command decr(K key) { + Command decr(K key) { notNullKey(key); - return createCommand(DECR, new IntegerOutput(codec), key); + return createCommand(DECR, new IntegerOutput<>(codec), key); } - public Command decrby(K key, long amount) { + Command decrby(K key, long amount) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(amount); - return createCommand(DECRBY, new IntegerOutput(codec), args); - } - - public Command del(K... keys) { - notEmpty(keys); - - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(DEL, new IntegerOutput(codec), args); - } - - public Command del(Iterable keys) { - LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(DEL, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(amount); + return createCommand(DECRBY, new IntegerOutput<>(codec), args); } - public Command unlink(K... keys) { + Command del(K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(UNLINK, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(DEL, new IntegerOutput<>(codec), args); } - public Command unlink(Iterable keys) { + Command del(Iterable keys) { LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(UNLINK, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(DEL, new IntegerOutput<>(codec), args); } - public Command discard() { - return createCommand(DISCARD, new StatusOutput(codec)); + Command discard() { + return createCommand(DISCARD, new StatusOutput<>(codec)); } - public Command dump(K key) { + Command dump(K key) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key); - return createCommand(DUMP, new ByteArrayOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key); + return createCommand(DUMP, new ByteArrayOutput<>(codec), args); } - public Command echo(V msg) { + Command echo(V msg) { LettuceAssert.notNull(msg, "message " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addValue(msg); - return createCommand(ECHO, new ValueOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addValue(msg); + return createCommand(ECHO, new ValueOutput<>(codec), args); } - public Command eval(String script, ScriptOutputType type, K... keys) { + Command eval(String script, ScriptOutputType type, K... keys) { LettuceAssert.notNull(script, "Script " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(script, "Script " + MUST_NOT_BE_EMPTY); LettuceAssert.notNull(type, "ScriptOutputType " + MUST_NOT_BE_NULL); LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(script).add(keys.length).addKeys(keys); CommandOutput output = newScriptOutput(codec, type); return createCommand(EVAL, output, args); } - public Command eval(String script, ScriptOutputType type, K[] keys, V... values) { + Command eval(String script, ScriptOutputType type, K[] keys, V... values) { LettuceAssert.notNull(script, "Script " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(script, "Script " + MUST_NOT_BE_EMPTY); LettuceAssert.notNull(type, "ScriptOutputType " + MUST_NOT_BE_NULL); LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); LettuceAssert.notNull(values, "Values " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(script).add(keys.length).addKeys(keys).addValues(values); CommandOutput output = newScriptOutput(codec, type); return createCommand(EVAL, output, args); } - public Command evalsha(String digest, ScriptOutputType type, K... keys) { + Command evalsha(String digest, ScriptOutputType type, K... keys) { LettuceAssert.notNull(digest, "Digest " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(digest, "Digest " + MUST_NOT_BE_EMPTY); LettuceAssert.notNull(type, "ScriptOutputType " + MUST_NOT_BE_NULL); LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(digest).add(keys.length).addKeys(keys); CommandOutput output = newScriptOutput(codec, type); return createCommand(EVALSHA, output, args); } - public Command evalsha(String digest, ScriptOutputType type, K[] keys, V... values) { + Command evalsha(String digest, ScriptOutputType type, K[] keys, V... values) { LettuceAssert.notNull(digest, "Digest " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(digest, "Digest " + MUST_NOT_BE_EMPTY); LettuceAssert.notNull(type, "ScriptOutputType " + MUST_NOT_BE_NULL); LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); LettuceAssert.notNull(values, "Values " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(digest).add(keys.length).addKeys(keys).addValues(values); CommandOutput output = newScriptOutput(codec, type); return createCommand(EVALSHA, output, args); } - public Command exists(K key) { + Command exists(K key) { notNullKey(key); - return createCommand(EXISTS, new BooleanOutput(codec), key); + return createCommand(EXISTS, new BooleanOutput<>(codec), key); } - public Command exists(K... keys) { + Command exists(K... keys) { notEmpty(keys); - return createCommand(EXISTS, new IntegerOutput(codec), new CommandArgs(codec).addKeys(keys)); + return createCommand(EXISTS, new IntegerOutput<>(codec), new CommandArgs<>(codec).addKeys(keys)); } - public Command exists(Iterable keys) { + Command exists(Iterable keys) { LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - return createCommand(EXISTS, new IntegerOutput(codec), new CommandArgs(codec).addKeys(keys)); + return createCommand(EXISTS, new IntegerOutput<>(codec), new CommandArgs<>(codec).addKeys(keys)); } - public Command expire(K key, long seconds) { + Command expire(K key, long seconds) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(seconds); - return createCommand(EXPIRE, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(seconds); + return createCommand(EXPIRE, new BooleanOutput<>(codec), args); } - public Command expireat(K key, long timestamp) { + Command expireat(K key, long timestamp) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(timestamp); - return createCommand(EXPIREAT, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(timestamp); + return createCommand(EXPIREAT, new BooleanOutput<>(codec), args); } - public Command flushall() { - return createCommand(FLUSHALL, new StatusOutput(codec)); + Command flushall() { + return createCommand(FLUSHALL, new StatusOutput<>(codec)); } - public Command flushallAsync() { - return createCommand(FLUSHALL, new StatusOutput(codec), new CommandArgs(codec).add(ASYNC)); + Command flushallAsync() { + return createCommand(FLUSHALL, new StatusOutput<>(codec), new CommandArgs<>(codec).add(ASYNC)); } - public Command flushdb() { - return createCommand(FLUSHDB, new StatusOutput(codec)); + Command flushdb() { + return createCommand(FLUSHDB, new StatusOutput<>(codec)); } - public Command flushdbAsync() { - return createCommand(FLUSHDB, new StatusOutput(codec), new CommandArgs(codec).add(ASYNC)); + Command flushdbAsync() { + return createCommand(FLUSHDB, new StatusOutput<>(codec), new CommandArgs<>(codec).add(ASYNC)); } - public Command get(K key) { + Command geoadd(K key, double longitude, double latitude, V member) { notNullKey(key); - return createCommand(GET, new ValueOutput(codec), key); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(longitude).add(latitude).addValue(member); + return createCommand(GEOADD, new IntegerOutput<>(codec), args); } - public Command getbit(K key, long offset) { + Command geoadd(K key, Object[] lngLatMember) { + notNullKey(key); + LettuceAssert.notNull(lngLatMember, "LngLatMember " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(lngLatMember, "LngLatMember " + MUST_NOT_BE_EMPTY); + LettuceAssert.noNullElements(lngLatMember, "LngLatMember " + MUST_NOT_CONTAIN_NULL_ELEMENTS); + LettuceAssert + .isTrue(lngLatMember.length % 3 == 0, + "LngLatMember.length must be a multiple of 3 and contain a " + + "sequence of longitude1, latitude1, member1, longitude2, latitude2, member2, ... longitudeN, latitudeN, memberN"); - CommandArgs args = new CommandArgs(codec).addKey(key).add(offset); - return createCommand(GETBIT, new IntegerOutput(codec), args); - } + CommandArgs args = new CommandArgs<>(codec).addKey(key); - public Command getrange(K key, long start, long end) { - notNullKey(key); + for (int i = 0; i < lngLatMember.length; i += 3) { + args.add((Double) lngLatMember[i]); + args.add((Double) lngLatMember[i + 1]); + args.addValue((V) lngLatMember[i + 2]); + } - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(end); - return createCommand(GETRANGE, new ValueOutput(codec), args); + return createCommand(GEOADD, new IntegerOutput<>(codec), args); } - public Command getset(K key, V value) { + Command geodist(K key, V from, V to, GeoArgs.Unit unit) { notNullKey(key); + LettuceAssert.notNull(from, "From " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(from, "To " + MUST_NOT_BE_NULL); - return createCommand(GETSET, new ValueOutput(codec), key, value); - } + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(from).addValue(to); - public Command hdel(K key, K... fields) { - notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + if (unit != null) { + args.add(unit.name()); + } - CommandArgs args = new CommandArgs(codec).addKey(key).addKeys(fields); - return createCommand(HDEL, new IntegerOutput(codec), args); + return createCommand(GEODIST, new DoubleOutput<>(codec), args); } - public Command hexists(K key, K field) { + Command> geohash(K key, V... members) { notNullKey(key); - LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field); - return createCommand(HEXISTS, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValues(members); + return createCommand(GEOHASH, new StringListOutput<>(codec), args); } - public Command hget(K key, K field) { + Command> geopos(K key, V[] members) { notNullKey(key); - LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValues(members); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field); - return createCommand(HGET, new ValueOutput(codec), args); + return createCommand(GEOPOS, new GeoCoordinatesListOutput<>(codec), args); } - public Command hincrby(K key, K field, long amount) { + Command> georadius(CommandType commandType, K key, double longitude, double latitude, double distance, + String unit) { notNullKey(key); - LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field).add(amount); - return createCommand(HINCRBY, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(longitude).add(latitude).add(distance).add(unit); + return createCommand(commandType, new ValueSetOutput<>(codec), args); } - public Command hincrbyfloat(K key, K field, double amount) { + Command>> georadius(CommandType commandType, K key, double longitude, double latitude, + double distance, String unit, GeoArgs geoArgs) { + notNullKey(key); - LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); + LettuceAssert.notNull(geoArgs, "GeoArgs " + MUST_NOT_BE_NULL); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(longitude).add(latitude).add(distance).add(unit); + geoArgs.build(args); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field).add(amount); - return createCommand(HINCRBYFLOAT, new DoubleOutput(codec), args); + return createCommand(commandType, new GeoWithinListOutput<>(codec, geoArgs.isWithDistance(), geoArgs.isWithHash(), + geoArgs.isWithCoordinates()), args); } - public Command> hgetall(K key) { + Command georadius(K key, double longitude, double latitude, double distance, String unit, + GeoRadiusStoreArgs geoRadiusStoreArgs) { + notNullKey(key); + LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); + LettuceAssert.notNull(geoRadiusStoreArgs, "GeoRadiusStoreArgs " + MUST_NOT_BE_NULL); + LettuceAssert.isTrue(geoRadiusStoreArgs.getStoreKey() != null || geoRadiusStoreArgs.getStoreDistKey() != null, + "At least STORE key or STORDIST key is required"); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(longitude).add(latitude).add(distance).add(unit); + geoRadiusStoreArgs.build(args); - return createCommand(HGETALL, new MapOutput(codec), key); + return createCommand(GEORADIUS, new IntegerOutput<>(codec), args); } - public Command hgetall(KeyValueStreamingChannel channel, K key) { + Command> georadiusbymember(CommandType commandType, K key, V member, double distance, String unit) { + notNullKey(key); - notNull(channel); + LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - return createCommand(HGETALL, new KeyValueStreamingOutput(codec, channel), key); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(member).add(distance).add(unit); + return createCommand(commandType, new ValueSetOutput<>(codec), args); } - public Command> hkeys(K key) { + Command>> georadiusbymember(CommandType commandType, K key, V member, double distance, String unit, + GeoArgs geoArgs) { + notNullKey(key); + LettuceAssert.notNull(geoArgs, "GeoArgs " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(member).add(distance).add(unit); + geoArgs.build(args); - return createCommand(HKEYS, new KeyListOutput(codec), key); + return createCommand(commandType, new GeoWithinListOutput<>(codec, geoArgs.isWithDistance(), geoArgs.isWithHash(), + geoArgs.isWithCoordinates()), args); } - public Command hkeys(KeyStreamingChannel channel, K key) { + Command georadiusbymember(K key, V member, double distance, String unit, + GeoRadiusStoreArgs geoRadiusStoreArgs) { + notNullKey(key); - notNull(channel); + LettuceAssert.notNull(geoRadiusStoreArgs, "GeoRadiusStoreArgs " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); + LettuceAssert.isTrue(geoRadiusStoreArgs.getStoreKey() != null || geoRadiusStoreArgs.getStoreDistKey() != null, + "At least STORE key or STORDIST key is required"); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(member).add(distance).add(unit); + geoRadiusStoreArgs.build(args); - return createCommand(HKEYS, new KeyStreamingOutput(codec, channel), key); + return createCommand(GEORADIUSBYMEMBER, new IntegerOutput<>(codec), args); } - public Command hlen(K key) { + Command get(K key) { notNullKey(key); - return createCommand(HLEN, new IntegerOutput(codec), key); + return createCommand(GET, new ValueOutput<>(codec), key); } - public Command hstrlen(K key, K field) { + Command getbit(K key, long offset) { notNullKey(key); - LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field); - return createCommand(HSTRLEN, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(offset); + return createCommand(GETBIT, new IntegerOutput<>(codec), args); } - public Command> hmget(K key, K... fields) { + Command getrange(K key, long start, long end) { notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKey(key).addKeys(fields); - return createCommand(HMGET, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(end); + return createCommand(GETRANGE, new ValueOutput<>(codec), args); } - public Command hmget(ValueStreamingChannel channel, K key, K... fields) { + Command getset(K key, V value) { notNullKey(key); - LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); - notNull(channel); - CommandArgs args = new CommandArgs(codec).addKey(key).addKeys(fields); - return createCommand(HMGET, new ValueStreamingOutput(codec, channel), args); + return createCommand(GETSET, new ValueOutput<>(codec), key, value); } - public Command hmset(K key, Map map) { + Command hdel(K key, K... fields) { notNullKey(key); - LettuceAssert.notNull(map, "Map " + MUST_NOT_BE_NULL); - LettuceAssert.isTrue(!map.isEmpty(), "Map " + MUST_NOT_BE_EMPTY); + LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKey(key).add(map); - return createCommand(HMSET, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); + return createCommand(HDEL, new IntegerOutput<>(codec), args); } - public Command hset(K key, K field, V value) { + Command hexists(K key, K field) { notNullKey(key); LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field).addValue(value); - return createCommand(HSET, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field); + return createCommand(HEXISTS, new BooleanOutput<>(codec), args); } - public Command hsetnx(K key, K field, V value) { + Command hget(K key, K field) { notNullKey(key); LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(field).addValue(value); - return createCommand(HSETNX, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field); + return createCommand(HGET, new ValueOutput<>(codec), args); } - public Command> hvals(K key) { + Command> hgetall(K key) { notNullKey(key); - return createCommand(HVALS, new ValueListOutput(codec), key); + return createCommand(HGETALL, new MapOutput<>(codec), key); } - public Command hvals(ValueStreamingChannel channel, K key) { + Command hgetall(KeyValueStreamingChannel channel, K key) { notNullKey(key); notNull(channel); - return createCommand(HVALS, new ValueStreamingOutput(codec, channel), key); + return createCommand(HGETALL, new KeyValueStreamingOutput<>(codec, channel), key); } - public Command incr(K key) { + Command hincrby(K key, K field, long amount) { notNullKey(key); + LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); - return createCommand(INCR, new IntegerOutput(codec), key); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field).add(amount); + return createCommand(HINCRBY, new IntegerOutput<>(codec), args); } - public Command incrby(K key, long amount) { + Command hincrbyfloat(K key, K field, double amount) { notNullKey(key); + LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).add(amount); - return createCommand(INCRBY, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field).add(amount); + return createCommand(HINCRBYFLOAT, new DoubleOutput<>(codec), args); } - public Command incrbyfloat(K key, double amount) { + Command> hkeys(K key) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(amount); - return createCommand(INCRBYFLOAT, new DoubleOutput(codec), args); - } - - public Command info() { - return createCommand(INFO, new StatusOutput(codec)); + return createCommand(HKEYS, new KeyListOutput<>(codec), key); } - public Command info(String section) { - LettuceAssert.notNull(section, "Section " + MUST_NOT_BE_NULL); + Command hkeys(KeyStreamingChannel channel, K key) { + notNullKey(key); + notNull(channel); - CommandArgs args = new CommandArgs(codec).add(section); - return createCommand(INFO, new StatusOutput(codec), args); + return createCommand(HKEYS, new KeyStreamingOutput<>(codec, channel), key); } - public Command> keys(K pattern) { - LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL); + Command hlen(K key) { + notNullKey(key); - return createCommand(KEYS, new KeyListOutput(codec), pattern); + return createCommand(HLEN, new IntegerOutput<>(codec), key); } - public Command keys(KeyStreamingChannel channel, K pattern) { - LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL); - notNull(channel); - - return createCommand(KEYS, new KeyStreamingOutput(codec, channel), pattern); - } + Command> hmget(K key, K... fields) { + notNullKey(key); + LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); - public Command lastsave() { - return createCommand(LASTSAVE, new DateOutput(codec)); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); + return createCommand(HMGET, new ValueListOutput<>(codec), args); } - public Command lindex(K key, long index) { + Command hmget(ValueStreamingChannel channel, K key, K... fields) { notNullKey(key); + LettuceAssert.notNull(fields, "Fields " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(fields, "Fields " + MUST_NOT_BE_EMPTY); + notNull(channel); - CommandArgs args = new CommandArgs(codec).addKey(key).add(index); - return createCommand(LINDEX, new ValueOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(fields); + return createCommand(HMGET, new ValueStreamingOutput<>(codec, channel), args); } - public Command linsert(K key, boolean before, V pivot, V value) { + Command hmset(K key, Map map) { notNullKey(key); + LettuceAssert.notNull(map, "Map " + MUST_NOT_BE_NULL); + LettuceAssert.isTrue(!map.isEmpty(), "Map " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(before ? BEFORE : AFTER).addValue(pivot).addValue(value); - return createCommand(LINSERT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(map); + return createCommand(HMSET, new StatusOutput<>(codec), args); } - public Command llen(K key) { + Command> hscan(K key) { notNullKey(key); - return createCommand(LLEN, new IntegerOutput(codec), key); + return hscan(key, ScanCursor.INITIAL, null); } - public Command lpop(K key) { + Command> hscan(K key, ScanCursor scanCursor) { notNullKey(key); - return createCommand(LPOP, new ValueOutput(codec), key); + return hscan(key, scanCursor, null); } - public Command lpush(K key, V... values) { + Command> hscan(K key, ScanArgs scanArgs) { notNullKey(key); - notEmptyValues(values); - return createCommand(LPUSH, new IntegerOutput(codec), key, values); + return hscan(key, ScanCursor.INITIAL, scanArgs); } - public Command lpushx(K key, V... values) { + Command> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { notNullKey(key); - notEmptyValues(values); - CommandArgs args = new CommandArgs(codec).addKey(key).addValues(values); + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key); + + scanArgs(scanCursor, scanArgs, args); - return createCommand(LPUSHX, new IntegerOutput(codec), args); + MapScanOutput output = new MapScanOutput<>(codec); + return createCommand(HSCAN, output, args); } - public Command> lrange(K key, long start, long stop) { + Command hscanStreaming(KeyValueStreamingChannel channel, K key) { notNullKey(key); + notNull(channel); + + return hscanStreaming(channel, key, ScanCursor.INITIAL, null); + } + + Command hscanStreaming(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor) { + notNullKey(key); + notNull(channel); + + return hscanStreaming(channel, key, scanCursor, null); + } + + Command hscanStreaming(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs) { + notNullKey(key); + notNull(channel); + + return hscanStreaming(channel, key, ScanCursor.INITIAL, scanArgs); + } + + Command hscanStreaming(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, + ScanArgs scanArgs) { + notNullKey(key); + notNull(channel); + + CommandArgs args = new CommandArgs<>(codec); + + args.addKey(key); + scanArgs(scanCursor, scanArgs, args); + + KeyValueScanStreamingOutput output = new KeyValueScanStreamingOutput<>(codec, channel); + return createCommand(HSCAN, output, args); + } + + Command hset(K key, K field, V value) { + notNullKey(key); + LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field).addValue(value); + return createCommand(HSET, new BooleanOutput<>(codec), args); + } + + Command hsetnx(K key, K field, V value) { + notNullKey(key); + LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field).addValue(value); + return createCommand(HSETNX, new BooleanOutput<>(codec), args); + } + + Command hstrlen(K key, K field) { + notNullKey(key); + LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(field); + return createCommand(HSTRLEN, new IntegerOutput<>(codec), args); + } + + Command> hvals(K key) { + notNullKey(key); + + return createCommand(HVALS, new ValueListOutput<>(codec), key); + } + + Command hvals(ValueStreamingChannel channel, K key) { + notNullKey(key); + notNull(channel); + + return createCommand(HVALS, new ValueStreamingOutput<>(codec, channel), key); + } + + Command incr(K key) { + notNullKey(key); + + return createCommand(INCR, new IntegerOutput<>(codec), key); + } + + Command incrby(K key, long amount) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(amount); + return createCommand(INCRBY, new IntegerOutput<>(codec), args); + } + + Command incrbyfloat(K key, double amount) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(amount); + return createCommand(INCRBYFLOAT, new DoubleOutput<>(codec), args); + } + + Command info() { + return createCommand(INFO, new StatusOutput<>(codec)); + } + + Command info(String section) { + LettuceAssert.notNull(section, "Section " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).add(section); + return createCommand(INFO, new StatusOutput<>(codec), args); + } + + Command> keys(K pattern) { + LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL); + + return createCommand(KEYS, new KeyListOutput<>(codec), pattern); + } + + Command keys(KeyStreamingChannel channel, K pattern) { + LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL); + notNull(channel); + + return createCommand(KEYS, new KeyStreamingOutput<>(codec, channel), pattern); + } + + Command lastsave() { + return createCommand(LASTSAVE, new DateOutput<>(codec)); + } + + Command lindex(K key, long index) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(index); + return createCommand(LINDEX, new ValueOutput<>(codec), args); + } + + Command linsert(K key, boolean before, V pivot, V value) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(before ? BEFORE : AFTER).addValue(pivot).addValue(value); + return createCommand(LINSERT, new IntegerOutput<>(codec), args); + } + + Command llen(K key) { + notNullKey(key); + + return createCommand(LLEN, new IntegerOutput<>(codec), key); + } + + Command lpop(K key) { + notNullKey(key); + + return createCommand(LPOP, new ValueOutput<>(codec), key); + } + + Command lpush(K key, V... values) { + notNullKey(key); + notEmptyValues(values); + + return createCommand(LPUSH, new IntegerOutput<>(codec), key, values); + } + + Command lpushx(K key, V... values) { + notNullKey(key); + notEmptyValues(values); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValues(values); + + return createCommand(LPUSHX, new IntegerOutput<>(codec), args); + } - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(LRANGE, new ValueListOutput(codec), args); + Command> lrange(K key, long start, long stop) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(LRANGE, new ValueListOutput<>(codec), args); } - public Command lrange(ValueStreamingChannel channel, K key, long start, long stop) { + Command lrange(ValueStreamingChannel channel, K key, long start, long stop) { notNullKey(key); notNull(channel); - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(LRANGE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(LRANGE, new ValueStreamingOutput<>(codec, channel), args); } - public Command lrem(K key, long count, V value) { + Command lrem(K key, long count, V value) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(count).addValue(value); - return createCommand(LREM, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(count).addValue(value); + return createCommand(LREM, new IntegerOutput<>(codec), args); } - public Command lset(K key, long index, V value) { + Command lset(K key, long index, V value) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(index).addValue(value); - return createCommand(LSET, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(index).addValue(value); + return createCommand(LSET, new StatusOutput<>(codec), args); } - public Command ltrim(K key, long start, long stop) { + Command ltrim(K key, long start, long stop) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(LTRIM, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(LTRIM, new StatusOutput<>(codec), args); + } + + Command> mget(K... keys) { + notEmpty(keys); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(MGET, new ValueListOutput<>(codec), args); + } + + Command> mget(Iterable keys) { + LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(MGET, new ValueListOutput<>(codec), args); + } + + Command mget(ValueStreamingChannel channel, K... keys) { + notEmpty(keys); + notNull(channel); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(MGET, new ValueStreamingOutput<>(codec, channel), args); + } + + Command mget(ValueStreamingChannel channel, Iterable keys) { + LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); + notNull(channel); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(MGET, new ValueStreamingOutput<>(codec, channel), args); } - public Command migrate(String host, int port, K key, int db, long timeout) { + Command migrate(String host, int port, K key, int db, long timeout) { LettuceAssert.notNull(host, "Host " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(host, "Host " + MUST_NOT_BE_EMPTY); notNullKey(key); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(host).add(port).addKey(key).add(db).add(timeout); - return createCommand(MIGRATE, new StatusOutput(codec), args); + return createCommand(MIGRATE, new StatusOutput<>(codec), args); } - public Command migrate(String host, int port, int db, long timeout, MigrateArgs migrateArgs) { + Command migrate(String host, int port, int db, long timeout, MigrateArgs migrateArgs) { LettuceAssert.notNull(host, "Host " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(host, "Host " + MUST_NOT_BE_EMPTY); LettuceAssert.notNull(migrateArgs, "migrateArgs " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.add(host).add(port); @@ -800,638 +1193,798 @@ public Command migrate(String host, int port, int db, long timeout args.add(db).add(timeout); migrateArgs.build(args); - return createCommand(MIGRATE, new StatusOutput(codec), args); + return createCommand(MIGRATE, new StatusOutput<>(codec), args); } - public Command> mget(K... keys) { - notEmpty(keys); + Command move(K key, int db) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(MGET, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(db); + return createCommand(MOVE, new BooleanOutput<>(codec), args); } - public Command> mget(Iterable keys) { - LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); + Command mset(Map map) { + LettuceAssert.notNull(map, "Map " + MUST_NOT_BE_NULL); + LettuceAssert.isTrue(!map.isEmpty(), "Map " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(MGET, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(map); + return createCommand(MSET, new StatusOutput<>(codec), args); } - public Command mget(ValueStreamingChannel channel, K... keys) { - notEmpty(keys); - notNull(channel); + Command msetnx(Map map) { + LettuceAssert.notNull(map, "Map " + MUST_NOT_BE_NULL); + LettuceAssert.isTrue(!map.isEmpty(), "Map " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(MGET, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec).add(map); + return createCommand(MSETNX, new BooleanOutput<>(codec), args); } - public Command mget(ValueStreamingChannel channel, Iterable keys) { - LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - notNull(channel); - - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(MGET, new ValueStreamingOutput(codec, channel), args); + Command multi() { + return createCommand(MULTI, new StatusOutput<>(codec)); } - public Command move(K key, int db) { + Command objectEncoding(K key) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(db); - return createCommand(MOVE, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(ENCODING).addKey(key); + return createCommand(OBJECT, new StatusOutput<>(codec), args); } - public Command multi() { - return createCommand(MULTI, new StatusOutput(codec)); + Command objectIdletime(K key) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).add(IDLETIME).addKey(key); + return createCommand(OBJECT, new IntegerOutput<>(codec), args); } - public Command mset(Map map) { - LettuceAssert.notNull(map, "Map " + MUST_NOT_BE_NULL); - LettuceAssert.isTrue(!map.isEmpty(), "Map " + MUST_NOT_BE_EMPTY); + Command objectRefcount(K key) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).add(map); - return createCommand(MSET, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(REFCOUNT).addKey(key); + return createCommand(OBJECT, new IntegerOutput<>(codec), args); } - public Command msetnx(Map map) { - LettuceAssert.notNull(map, "Map " + MUST_NOT_BE_NULL); - LettuceAssert.isTrue(!map.isEmpty(), "Map " + MUST_NOT_BE_EMPTY); + Command persist(K key) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).add(map); - return createCommand(MSETNX, new BooleanOutput(codec), args); + return createCommand(PERSIST, new BooleanOutput<>(codec), key); } - public Command objectEncoding(K key) { + Command pexpire(K key, long milliseconds) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).add(ENCODING).addKey(key); - return createCommand(OBJECT, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(milliseconds); + return createCommand(PEXPIRE, new BooleanOutput<>(codec), args); } - public Command objectIdletime(K key) { + Command pexpireat(K key, long timestamp) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).add(IDLETIME).addKey(key); - return createCommand(OBJECT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(timestamp); + return createCommand(PEXPIREAT, new BooleanOutput<>(codec), args); } - public Command objectRefcount(K key) { + Command pfadd(K key, V value, V... moreValues) { notNullKey(key); + LettuceAssert.notNull(value, "Value " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(moreValues, "MoreValues " + MUST_NOT_BE_NULL); + LettuceAssert.noNullElements(moreValues, "MoreValues " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - CommandArgs args = new CommandArgs(codec).add(REFCOUNT).addKey(key); - return createCommand(OBJECT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(value).addValues(moreValues); + return createCommand(PFADD, new IntegerOutput<>(codec), args); } - public Command persist(K key) { + Command pfadd(K key, V... values) { notNullKey(key); + notEmptyValues(values); + LettuceAssert.noNullElements(values, "Values " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - return createCommand(PERSIST, new BooleanOutput(codec), key); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValues(values); + return createCommand(PFADD, new IntegerOutput<>(codec), args); } - public Command pexpire(K key, long milliseconds) { + Command pfcount(K key, K... moreKeys) { notNullKey(key); + LettuceAssert.notNull(moreKeys, "MoreKeys " + MUST_NOT_BE_NULL); + LettuceAssert.noNullElements(moreKeys, "MoreKeys " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - CommandArgs args = new CommandArgs(codec).addKey(key).add(milliseconds); - return createCommand(PEXPIRE, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKeys(moreKeys); + return createCommand(PFCOUNT, new IntegerOutput<>(codec), args); } - public Command pexpireat(K key, long timestamp) { - notNullKey(key); + Command pfcount(K... keys) { + notEmpty(keys); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(PFCOUNT, new IntegerOutput<>(codec), args); + } + + @SuppressWarnings("unchecked") + Command pfmerge(K destkey, K sourcekey, K... moreSourceKeys) { + LettuceAssert.notNull(destkey, "Destkey " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(sourcekey, "Sourcekey " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(moreSourceKeys, "MoreSourceKeys " + MUST_NOT_BE_NULL); + LettuceAssert.noNullElements(moreSourceKeys, "MoreSourceKeys " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - CommandArgs args = new CommandArgs(codec).addKey(key).add(timestamp); - return createCommand(PEXPIREAT, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(destkey).addKey(sourcekey).addKeys(moreSourceKeys); + return createCommand(PFMERGE, new StatusOutput<>(codec), args); } - public Command ping() { - return createCommand(PING, new StatusOutput(codec)); + @SuppressWarnings("unchecked") + Command pfmerge(K destkey, K... sourcekeys) { + LettuceAssert.notNull(destkey, "Destkey " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(sourcekeys, "Sourcekeys " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(sourcekeys, "Sourcekeys " + MUST_NOT_BE_EMPTY); + LettuceAssert.noNullElements(sourcekeys, "Sourcekeys " + MUST_NOT_CONTAIN_NULL_ELEMENTS); + + CommandArgs args = new CommandArgs<>(codec).addKeys(destkey).addKeys(sourcekeys); + return createCommand(PFMERGE, new StatusOutput<>(codec), args); } - public Command readOnly() { - return createCommand(READONLY, new StatusOutput(codec)); + Command ping() { + return createCommand(PING, new StatusOutput<>(codec)); } - public Command readWrite() { - return createCommand(READWRITE, new StatusOutput(codec)); + Command psetex(K key, long milliseconds, V value) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(milliseconds).addValue(value); + return createCommand(PSETEX, new StatusOutput<>(codec), args); } - public Command pttl(K key) { + Command pttl(K key) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key); - return createCommand(PTTL, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key); + return createCommand(PTTL, new IntegerOutput<>(codec), args); } - public Command publish(K channel, V message) { + Command publish(K channel, V message) { LettuceAssert.notNull(channel, "Channel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(channel).addValue(message); - return createCommand(PUBLISH, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(channel).addValue(message); + return createCommand(PUBLISH, new IntegerOutput<>(codec), args); } - public Command> pubsubChannels() { - CommandArgs args = new CommandArgs(codec).add(CHANNELS); - return createCommand(PUBSUB, new KeyListOutput(codec), args); + Command> pubsubChannels() { + CommandArgs args = new CommandArgs<>(codec).add(CHANNELS); + return createCommand(PUBSUB, new KeyListOutput<>(codec), args); } - public Command> pubsubChannels(K pattern) { + Command> pubsubChannels(K pattern) { LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).add(CHANNELS).addKey(pattern); - return createCommand(PUBSUB, new KeyListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(CHANNELS).addKey(pattern); + return createCommand(PUBSUB, new KeyListOutput<>(codec), args); + } + + Command pubsubNumpat() { + CommandArgs args = new CommandArgs<>(codec).add(NUMPAT); + return createCommand(PUBSUB, new IntegerOutput<>(codec), args); } @SuppressWarnings({ "unchecked", "rawtypes" }) - public Command> pubsubNumsub(K... pattern) { + Command> pubsubNumsub(K... pattern) { LettuceAssert.notNull(pattern, "Pattern " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(pattern, "Pattern " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).add(NUMSUB).addKeys(pattern); + CommandArgs args = new CommandArgs<>(codec).add(NUMSUB).addKeys(pattern); return createCommand(PUBSUB, (MapOutput) new MapOutput((RedisCodec) codec), args); } - public Command pubsubNumpat() { - CommandArgs args = new CommandArgs(codec).add(NUMPAT); - return createCommand(PUBSUB, new IntegerOutput(codec), args); + Command quit() { + return createCommand(QUIT, new StatusOutput<>(codec)); } - public Command quit() { - return createCommand(QUIT, new StatusOutput(codec)); + Command randomkey() { + return createCommand(RANDOMKEY, new ValueOutput<>(codec)); } - public Command randomkey() { - return createCommand(RANDOMKEY, new ValueOutput(codec)); + Command readOnly() { + return createCommand(READONLY, new StatusOutput<>(codec)); } - public Command> role() { - return createCommand(ROLE, new ArrayOutput(codec)); + Command readWrite() { + return createCommand(READWRITE, new StatusOutput<>(codec)); } - public Command rename(K key, K newKey) { + Command rename(K key, K newKey) { notNullKey(key); LettuceAssert.notNull(newKey, "NewKey " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(newKey); - return createCommand(RENAME, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(newKey); + return createCommand(RENAME, new StatusOutput<>(codec), args); } - public Command renamenx(K key, K newKey) { + Command renamenx(K key, K newKey) { notNullKey(key); LettuceAssert.notNull(newKey, "NewKey " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).addKey(newKey); - return createCommand(RENAMENX, new BooleanOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addKey(newKey); + return createCommand(RENAMENX, new BooleanOutput<>(codec), args); } - public Command restore(K key, long ttl, byte[] value) { + Command restore(K key, long ttl, byte[] value) { notNullKey(key); LettuceAssert.notNull(value, "Value " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).add(ttl).add(value); - return createCommand(RESTORE, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(ttl).add(value); + return createCommand(RESTORE, new StatusOutput<>(codec), args); + } + + Command> role() { + return createCommand(ROLE, new ArrayOutput<>(codec)); } - public Command rpop(K key) { + Command rpop(K key) { notNullKey(key); - return createCommand(RPOP, new ValueOutput(codec), key); + return createCommand(RPOP, new ValueOutput<>(codec), key); } - public Command rpoplpush(K source, K destination) { + Command rpoplpush(K source, K destination) { LettuceAssert.notNull(source, "Source " + MUST_NOT_BE_NULL); LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(source).addKey(destination); - return createCommand(RPOPLPUSH, new ValueOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(source).addKey(destination); + return createCommand(RPOPLPUSH, new ValueOutput<>(codec), args); } - public Command rpush(K key, V... values) { + Command rpush(K key, V... values) { notNullKey(key); notEmptyValues(values); - return createCommand(RPUSH, new IntegerOutput(codec), key, values); + return createCommand(RPUSH, new IntegerOutput<>(codec), key, values); } - public Command rpushx(K key, V... values) { + Command rpushx(K key, V... values) { notNullKey(key); notEmptyValues(values); - CommandArgs args = new CommandArgs(codec).addKey(key).addValues(values); - return createCommand(RPUSHX, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValues(values); + return createCommand(RPUSHX, new IntegerOutput<>(codec), args); } - public Command sadd(K key, V... members) { + Command sadd(K key, V... members) { notNullKey(key); LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); - return createCommand(SADD, new IntegerOutput(codec), key, members); + return createCommand(SADD, new IntegerOutput<>(codec), key, members); + } + + Command save() { + return createCommand(SAVE, new StatusOutput<>(codec)); + } + + Command> scan() { + return scan(ScanCursor.INITIAL, null); + } + + Command> scan(ScanCursor scanCursor) { + return scan(scanCursor, null); + } + + Command> scan(ScanArgs scanArgs) { + return scan(ScanCursor.INITIAL, scanArgs); + } + + Command> scan(ScanCursor scanCursor, ScanArgs scanArgs) { + CommandArgs args = new CommandArgs<>(codec); + + scanArgs(scanCursor, scanArgs, args); + + KeyScanOutput output = new KeyScanOutput<>(codec); + return createCommand(SCAN, output, args); + } + + protected void scanArgs(ScanCursor scanCursor, ScanArgs scanArgs, CommandArgs args) { + LettuceAssert.notNull(scanCursor, "ScanCursor " + MUST_NOT_BE_NULL); + LettuceAssert.isTrue(!scanCursor.isFinished(), "ScanCursor must not be finished"); + + args.add(scanCursor.getCursor()); + + if (scanArgs != null) { + scanArgs.build(args); + } + } + + Command scanStreaming(KeyStreamingChannel channel) { + notNull(channel); + LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); + + return scanStreaming(channel, ScanCursor.INITIAL, null); + } + + Command scanStreaming(KeyStreamingChannel channel, ScanCursor scanCursor) { + notNull(channel); + LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); + + return scanStreaming(channel, scanCursor, null); + } + + Command scanStreaming(KeyStreamingChannel channel, ScanArgs scanArgs) { + notNull(channel); + LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); + + return scanStreaming(channel, ScanCursor.INITIAL, scanArgs); } - public Command save() { - return createCommand(SAVE, new StatusOutput(codec)); + Command scanStreaming(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs) { + notNull(channel); + LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec); + scanArgs(scanCursor, scanArgs, args); + + KeyScanStreamingOutput output = new KeyScanStreamingOutput<>(codec, channel); + return createCommand(SCAN, output, args); } - public Command scard(K key) { + Command scard(K key) { notNullKey(key); - return createCommand(SCARD, new IntegerOutput(codec), key); + return createCommand(SCARD, new IntegerOutput<>(codec), key); } - public Command> scriptExists(String... digests) { + Command> scriptExists(String... digests) { LettuceAssert.notNull(digests, "Digests " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(digests, "Digests " + MUST_NOT_BE_EMPTY); LettuceAssert.noNullElements(digests, "Digests " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - CommandArgs args = new CommandArgs(codec).add(EXISTS); + CommandArgs args = new CommandArgs<>(codec).add(EXISTS); for (String sha : digests) { args.add(sha); } - return createCommand(SCRIPT, new BooleanListOutput(codec), args); + return createCommand(SCRIPT, new BooleanListOutput<>(codec), args); } - public Command scriptFlush() { - CommandArgs args = new CommandArgs(codec).add(FLUSH); - return createCommand(SCRIPT, new StatusOutput(codec), args); + Command scriptFlush() { + CommandArgs args = new CommandArgs<>(codec).add(FLUSH); + return createCommand(SCRIPT, new StatusOutput<>(codec), args); } - public Command scriptKill() { - CommandArgs args = new CommandArgs(codec).add(KILL); - return createCommand(SCRIPT, new StatusOutput(codec), args); + Command scriptKill() { + CommandArgs args = new CommandArgs<>(codec).add(KILL); + return createCommand(SCRIPT, new StatusOutput<>(codec), args); } - public Command scriptLoad(V script) { + Command scriptLoad(V script) { LettuceAssert.notNull(script, "Script " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).add(LOAD).addValue(script); - return createCommand(SCRIPT, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(LOAD).addValue(script); + return createCommand(SCRIPT, new StatusOutput<>(codec), args); } - public Command> sdiff(K... keys) { + Command> sdiff(K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(SDIFF, new ValueSetOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(SDIFF, new ValueSetOutput<>(codec), args); } - public Command sdiff(ValueStreamingChannel channel, K... keys) { + Command sdiff(ValueStreamingChannel channel, K... keys) { notEmpty(keys); notNull(channel); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(SDIFF, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(SDIFF, new ValueStreamingOutput<>(codec, channel), args); } - public Command sdiffstore(K destination, K... keys) { + Command sdiffstore(K destination, K... keys) { notEmpty(keys); LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(destination).addKeys(keys); - return createCommand(SDIFFSTORE, new IntegerOutput(codec), args); - } - - public Command select(int db) { - CommandArgs args = new CommandArgs(codec).add(db); - return createCommand(SELECT, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(destination).addKeys(keys); + return createCommand(SDIFFSTORE, new IntegerOutput<>(codec), args); } - public Command swapdb(int db1, int db2) { - CommandArgs args = new CommandArgs(codec).add(db1).add(db2); - return createCommand(SWAPDB, new StatusOutput(codec), args); + Command select(int db) { + CommandArgs args = new CommandArgs<>(codec).add(db); + return createCommand(SELECT, new StatusOutput<>(codec), args); } - public Command set(K key, V value) { + Command set(K key, V value) { notNullKey(key); - return createCommand(SET, new StatusOutput(codec), key, value); + return createCommand(SET, new StatusOutput<>(codec), key, value); } - public Command set(K key, V value, SetArgs setArgs) { + Command set(K key, V value, SetArgs setArgs) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).addValue(value); + CommandArgs args = new CommandArgs<>(codec).addKey(key).addValue(value); setArgs.build(args); - return createCommand(SET, new StatusOutput(codec), args); - } - - public Command setbit(K key, long offset, int value) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec).addKey(key).add(offset).add(value); - return createCommand(SETBIT, new IntegerOutput(codec), args); + return createCommand(SET, new StatusOutput<>(codec), args); } - public Command setex(K key, long seconds, V value) { + Command setbit(K key, long offset, int value) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(seconds).addValue(value); - return createCommand(SETEX, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(offset).add(value); + return createCommand(SETBIT, new IntegerOutput<>(codec), args); } - public Command psetex(K key, long milliseconds, V value) { + Command setex(K key, long seconds, V value) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(milliseconds).addValue(value); - return createCommand(PSETEX, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(seconds).addValue(value); + return createCommand(SETEX, new StatusOutput<>(codec), args); } - public Command setnx(K key, V value) { + Command setnx(K key, V value) { notNullKey(key); - return createCommand(SETNX, new BooleanOutput(codec), key, value); + return createCommand(SETNX, new BooleanOutput<>(codec), key, value); } - public Command setrange(K key, long offset, V value) { + Command setrange(K key, long offset, V value) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(offset).addValue(value); - return createCommand(SETRANGE, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(offset).addValue(value); + return createCommand(SETRANGE, new IntegerOutput<>(codec), args); } @Deprecated - public Command shutdown() { - return createCommand(SHUTDOWN, new StatusOutput(codec)); + Command shutdown() { + return createCommand(SHUTDOWN, new StatusOutput<>(codec)); } - public Command shutdown(boolean save) { - CommandArgs args = new CommandArgs(codec); - return createCommand(SHUTDOWN, new StatusOutput(codec), save ? args.add(SAVE) : args.add(NOSAVE)); + Command shutdown(boolean save) { + CommandArgs args = new CommandArgs<>(codec); + return createCommand(SHUTDOWN, new StatusOutput<>(codec), save ? args.add(SAVE) : args.add(NOSAVE)); } - public Command> sinter(K... keys) { + Command> sinter(K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(SINTER, new ValueSetOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(SINTER, new ValueSetOutput<>(codec), args); } - public Command sinter(ValueStreamingChannel channel, K... keys) { + Command sinter(ValueStreamingChannel channel, K... keys) { notEmpty(keys); notNull(channel); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(SINTER, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(SINTER, new ValueStreamingOutput<>(codec, channel), args); } - public Command sinterstore(K destination, K... keys) { + Command sinterstore(K destination, K... keys) { LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKey(destination).addKeys(keys); - return createCommand(SINTERSTORE, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(destination).addKeys(keys); + return createCommand(SINTERSTORE, new IntegerOutput<>(codec), args); } - public Command sismember(K key, V member) { + Command sismember(K key, V member) { notNullKey(key); - return createCommand(SISMEMBER, new BooleanOutput(codec), key, member); - } - - public Command smove(K source, K destination, V member) { - LettuceAssert.notNull(source, "Source " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); - - CommandArgs args = new CommandArgs(codec).addKey(source).addKey(destination).addValue(member); - return createCommand(SMOVE, new BooleanOutput(codec), args); + return createCommand(SISMEMBER, new BooleanOutput<>(codec), key, member); } - public Command slaveof(String host, int port) { + Command slaveof(String host, int port) { LettuceAssert.notNull(host, "Host " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(host, "Host " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).add(host).add(port); - return createCommand(SLAVEOF, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).add(host).add(port); + return createCommand(SLAVEOF, new StatusOutput<>(codec), args); } - public Command slaveofNoOne() { - CommandArgs args = new CommandArgs(codec).add(NO).add(ONE); - return createCommand(SLAVEOF, new StatusOutput(codec), args); + Command slaveofNoOne() { + CommandArgs args = new CommandArgs<>(codec).add(NO).add(ONE); + return createCommand(SLAVEOF, new StatusOutput<>(codec), args); } - public Command> slowlogGet() { - CommandArgs args = new CommandArgs(codec).add(GET); - return createCommand(SLOWLOG, new NestedMultiOutput(codec), args); + Command> slowlogGet() { + CommandArgs args = new CommandArgs<>(codec).add(GET); + return createCommand(SLOWLOG, new NestedMultiOutput<>(codec), args); } - public Command> slowlogGet(int count) { - CommandArgs args = new CommandArgs(codec).add(GET).add(count); - return createCommand(SLOWLOG, new NestedMultiOutput(codec), args); + Command> slowlogGet(int count) { + CommandArgs args = new CommandArgs<>(codec).add(GET).add(count); + return createCommand(SLOWLOG, new NestedMultiOutput<>(codec), args); } - public Command slowlogLen() { - CommandArgs args = new CommandArgs(codec).add(LEN); - return createCommand(SLOWLOG, new IntegerOutput(codec), args); + Command slowlogLen() { + CommandArgs args = new CommandArgs<>(codec).add(LEN); + return createCommand(SLOWLOG, new IntegerOutput<>(codec), args); } - public Command slowlogReset() { - CommandArgs args = new CommandArgs(codec).add(RESET); - return createCommand(SLOWLOG, new StatusOutput(codec), args); + Command slowlogReset() { + CommandArgs args = new CommandArgs<>(codec).add(RESET); + return createCommand(SLOWLOG, new StatusOutput<>(codec), args); } - public Command> smembers(K key) { + Command> smembers(K key) { notNullKey(key); - return createCommand(SMEMBERS, new ValueSetOutput(codec), key); + return createCommand(SMEMBERS, new ValueSetOutput<>(codec), key); } - public Command smembers(ValueStreamingChannel channel, K key) { + Command smembers(ValueStreamingChannel channel, K key) { notNullKey(key); notNull(channel); - return createCommand(SMEMBERS, new ValueStreamingOutput(codec, channel), key); + return createCommand(SMEMBERS, new ValueStreamingOutput<>(codec, channel), key); } - public Command> sort(K key) { + Command smove(K source, K destination, V member) { + LettuceAssert.notNull(source, "Source " + MUST_NOT_BE_NULL); + LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); + + CommandArgs args = new CommandArgs<>(codec).addKey(source).addKey(destination).addValue(member); + return createCommand(SMOVE, new BooleanOutput<>(codec), args); + } + + Command> sort(K key) { notNullKey(key); - return createCommand(SORT, new ValueListOutput(codec), key); + return createCommand(SORT, new ValueListOutput<>(codec), key); } - public Command> sort(K key, SortArgs sortArgs) { + Command> sort(K key, SortArgs sortArgs) { notNullKey(key); LettuceAssert.notNull(sortArgs, "SortArgs " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key); + CommandArgs args = new CommandArgs<>(codec).addKey(key); sortArgs.build(args, null); - return createCommand(SORT, new ValueListOutput(codec), args); + return createCommand(SORT, new ValueListOutput<>(codec), args); } - public Command sort(ValueStreamingChannel channel, K key) { + Command sort(ValueStreamingChannel channel, K key) { notNullKey(key); notNull(channel); - return createCommand(SORT, new ValueStreamingOutput(codec, channel), key); + return createCommand(SORT, new ValueStreamingOutput<>(codec, channel), key); } - public Command sort(ValueStreamingChannel channel, K key, SortArgs sortArgs) { + Command sort(ValueStreamingChannel channel, K key, SortArgs sortArgs) { notNullKey(key); notNull(channel); LettuceAssert.notNull(sortArgs, "SortArgs " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key); + CommandArgs args = new CommandArgs<>(codec).addKey(key); sortArgs.build(args, null); - return createCommand(SORT, new ValueStreamingOutput(codec, channel), args); + return createCommand(SORT, new ValueStreamingOutput<>(codec, channel), args); } - public Command sortStore(K key, SortArgs sortArgs, K destination) { + Command sortStore(K key, SortArgs sortArgs, K destination) { notNullKey(key); LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); LettuceAssert.notNull(sortArgs, "SortArgs " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key); + CommandArgs args = new CommandArgs<>(codec).addKey(key); sortArgs.build(args, destination); - return createCommand(SORT, new IntegerOutput(codec), args); + return createCommand(SORT, new IntegerOutput<>(codec), args); } - public Command spop(K key) { + Command spop(K key) { notNullKey(key); - return createCommand(SPOP, new ValueOutput(codec), key); + return createCommand(SPOP, new ValueOutput<>(codec), key); } - public Command> spop(K key, long count) { + Command> spop(K key, long count) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(count); - return createCommand(SPOP, new ValueSetOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(count); + return createCommand(SPOP, new ValueSetOutput<>(codec), args); } - public Command srandmember(K key) { + Command srandmember(K key) { notNullKey(key); - return createCommand(SRANDMEMBER, new ValueOutput(codec), key); + return createCommand(SRANDMEMBER, new ValueOutput<>(codec), key); } - public Command> srandmember(K key, long count) { + Command> srandmember(K key, long count) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(count); - return createCommand(SRANDMEMBER, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(count); + return createCommand(SRANDMEMBER, new ValueListOutput<>(codec), args); } - public Command srandmember(ValueStreamingChannel channel, K key, long count) { + Command srandmember(ValueStreamingChannel channel, K key, long count) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(count); - return createCommand(SRANDMEMBER, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(count); + return createCommand(SRANDMEMBER, new ValueStreamingOutput<>(codec, channel), args); } - public Command srem(K key, V... members) { + Command srem(K key, V... members) { notNullKey(key); LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); - return createCommand(SREM, new IntegerOutput(codec), key, members); + return createCommand(SREM, new IntegerOutput<>(codec), key, members); } - public Command> sunion(K... keys) { - notEmpty(keys); + Command> sscan(K key) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(SUNION, new ValueSetOutput(codec), args); + return sscan(key, ScanCursor.INITIAL, null); } - public Command sunion(ValueStreamingChannel channel, K... keys) { - notEmpty(keys); - notNull(channel); + Command> sscan(K key, ScanCursor scanCursor) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(SUNION, new ValueStreamingOutput(codec, channel), args); + return sscan(key, scanCursor, null); } - public Command sunionstore(K destination, K... keys) { - LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); - notEmpty(keys); + Command> sscan(K key, ScanArgs scanArgs) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(destination).addKeys(keys); - return createCommand(SUNIONSTORE, new IntegerOutput(codec), args); + return sscan(key, ScanCursor.INITIAL, scanArgs); } - public Command sync() { - return createCommand(SYNC, new StatusOutput(codec)); + Command> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key); + + scanArgs(scanCursor, scanArgs, args); + + ValueScanOutput output = new ValueScanOutput<>(codec); + return createCommand(SSCAN, output, args); + } + + Command sscanStreaming(ValueStreamingChannel channel, K key) { + notNullKey(key); + notNull(channel); + + return sscanStreaming(channel, key, ScanCursor.INITIAL, null); + } + + Command sscanStreaming(ValueStreamingChannel channel, K key, ScanCursor scanCursor) { + notNullKey(key); + notNull(channel); + + return sscanStreaming(channel, key, scanCursor, null); + } + + Command sscanStreaming(ValueStreamingChannel channel, K key, ScanArgs scanArgs) { + notNullKey(key); + notNull(channel); + + return sscanStreaming(channel, key, ScanCursor.INITIAL, scanArgs); + } + + Command sscanStreaming(ValueStreamingChannel channel, K key, ScanCursor scanCursor, + ScanArgs scanArgs) { + notNullKey(key); + notNull(channel); + + CommandArgs args = new CommandArgs<>(codec); + + args.addKey(key); + scanArgs(scanCursor, scanArgs, args); + + ValueScanStreamingOutput output = new ValueScanStreamingOutput<>(codec, channel); + return createCommand(SSCAN, output, args); } - public Command strlen(K key) { + Command strlen(K key) { notNullKey(key); - return createCommand(STRLEN, new IntegerOutput(codec), key); + return createCommand(STRLEN, new IntegerOutput<>(codec), key); + } + + Command> sunion(K... keys) { + notEmpty(keys); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(SUNION, new ValueSetOutput<>(codec), args); + } + + Command sunion(ValueStreamingChannel channel, K... keys) { + notEmpty(keys); + notNull(channel); + + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(SUNION, new ValueStreamingOutput<>(codec, channel), args); + } + + Command sunionstore(K destination, K... keys) { + LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); + notEmpty(keys); + + CommandArgs args = new CommandArgs<>(codec).addKey(destination).addKeys(keys); + return createCommand(SUNIONSTORE, new IntegerOutput<>(codec), args); + } + + Command swapdb(int db1, int db2) { + CommandArgs args = new CommandArgs<>(codec).add(db1).add(db2); + return createCommand(SWAPDB, new StatusOutput<>(codec), args); + } + + Command sync() { + return createCommand(SYNC, new StatusOutput<>(codec)); + } + + Command> time() { + CommandArgs args = new CommandArgs<>(codec); + return createCommand(TIME, new ValueListOutput<>(codec), args); } - public Command touch(K... keys) { + Command touch(K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(TOUCH, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(TOUCH, new IntegerOutput<>(codec), args); } - public Command touch(Iterable keys) { + Command touch(Iterable keys) { LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(TOUCH, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(TOUCH, new IntegerOutput<>(codec), args); } - public Command ttl(K key) { + Command ttl(K key) { notNullKey(key); - return createCommand(TTL, new IntegerOutput(codec), key); + return createCommand(TTL, new IntegerOutput<>(codec), key); } - public Command type(K key) { + Command type(K key) { notNullKey(key); - return createCommand(TYPE, new StatusOutput(codec), key); + return createCommand(TYPE, new StatusOutput<>(codec), key); } - public Command watch(K... keys) { + Command unlink(K... keys) { notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(WATCH, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(UNLINK, new IntegerOutput<>(codec), args); } - public Command wait(int replicas, long timeout) { - CommandArgs args = new CommandArgs(codec).add(replicas).add(timeout); + Command unlink(Iterable keys) { + LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - return createCommand(WAIT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(UNLINK, new IntegerOutput<>(codec), args); } - public Command unwatch() { - return createCommand(UNWATCH, new StatusOutput(codec)); + Command unwatch() { + return createCommand(UNWATCH, new StatusOutput<>(codec)); } - public Command zadd(K key, ZAddArgs zAddArgs, double score, V member) { - notNullKey(key); + Command wait(int replicas, long timeout) { + CommandArgs args = new CommandArgs<>(codec).add(replicas).add(timeout); - CommandArgs args = new CommandArgs(codec).addKey(key); + return createCommand(WAIT, new IntegerOutput<>(codec), args); + } - if (zAddArgs != null) { - zAddArgs.build(args); - } - args.add(score).addValue(member); + Command watch(K... keys) { + notEmpty(keys); - return createCommand(ZADD, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKeys(keys); + return createCommand(WATCH, new StatusOutput<>(codec), args); } - public Command zaddincr(K key, ZAddArgs zAddArgs, double score, V member) { + Command zadd(K key, ZAddArgs zAddArgs, double score, V member) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key); + CommandArgs args = new CommandArgs<>(codec).addKey(key); if (zAddArgs != null) { zAddArgs.build(args); } - - args.add(INCR); args.add(score).addValue(member); - return createCommand(ZADD, new DoubleOutput(codec), args); + return createCommand(ZADD, new IntegerOutput<>(codec), args); } @SuppressWarnings("unchecked") - public Command zadd(K key, ZAddArgs zAddArgs, Object... scoresAndValues) { + Command zadd(K key, ZAddArgs zAddArgs, Object... scoresAndValues) { notNullKey(key); LettuceAssert.notNull(scoresAndValues, "ScoresAndValues " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(scoresAndValues, "ScoresAndValues " + MUST_NOT_BE_EMPTY); LettuceAssert.noNullElements(scoresAndValues, "ScoresAndValues " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - CommandArgs args = new CommandArgs(codec).addKey(key); + CommandArgs args = new CommandArgs<>(codec).addKey(key); if (zAddArgs != null) { zAddArgs.build(args); @@ -1457,464 +2010,532 @@ public Command zadd(K key, ZAddArgs zAddArgs, Object... scoresAndVal } } - return createCommand(ZADD, new IntegerOutput(codec), args); + return createCommand(ZADD, new IntegerOutput<>(codec), args); } - private boolean allElementsInstanceOf(Object[] objects, Class expectedAssignableType) { + Command zaddincr(K key, ZAddArgs zAddArgs, double score, V member) { + notNullKey(key); - for (Object object : objects) { - if (!expectedAssignableType.isAssignableFrom(object.getClass())) { - return false; - } + CommandArgs args = new CommandArgs<>(codec).addKey(key); + + if (zAddArgs != null) { + zAddArgs.build(args); } - return true; + args.add(INCR); + args.add(score).addValue(member); + + return createCommand(ZADD, new DoubleOutput<>(codec), args); } - public Command zcard(K key) { + Command zcard(K key) { notNullKey(key); - return createCommand(ZCARD, new IntegerOutput(codec), key); + return createCommand(ZCARD, new IntegerOutput<>(codec), key); } - public Command zcount(K key, double min, double max) { + Command zcount(K key, double min, double max) { return zcount(key, string(min), string(max)); } - public Command zcount(K key, String min, String max) { + Command zcount(K key, String min, String max) { notNullKey(key); notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec).addKey(key).add(min).add(max); - return createCommand(ZCOUNT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(min).add(max); + return createCommand(ZCOUNT, new IntegerOutput<>(codec), args); } - public Command zcount(K key, Range range) { + Command zcount(K key, Range range) { notNullKey(key); notNullRange(range); - CommandArgs args = new CommandArgs(codec).addKey(key).add(min(range)).add(max(range)); - return createCommand(ZCOUNT, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(min(range)).add(max(range)); + return createCommand(ZCOUNT, new IntegerOutput<>(codec), args); } - public Command zincrby(K key, double amount, K member) { + Command zincrby(K key, double amount, K member) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(amount).addKey(member); - return createCommand(ZINCRBY, new DoubleOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(amount).addKey(member); + return createCommand(ZINCRBY, new DoubleOutput<>(codec), args); } - public Command zinterstore(K destination, K... keys) { + Command zinterstore(K destination, K... keys) { notEmpty(keys); return zinterstore(destination, new ZStoreArgs(), keys); } - public Command zinterstore(K destination, ZStoreArgs storeArgs, K... keys) { + Command zinterstore(K destination, ZStoreArgs storeArgs, K... keys) { LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); LettuceAssert.notNull(storeArgs, "ZStoreArgs " + MUST_NOT_BE_NULL); notEmpty(keys); - CommandArgs args = new CommandArgs(codec).addKey(destination).add(keys.length).addKeys(keys); + CommandArgs args = new CommandArgs<>(codec).addKey(destination).add(keys.length).addKeys(keys); storeArgs.build(args); - return createCommand(ZINTERSTORE, new IntegerOutput(codec), args); + return createCommand(ZINTERSTORE, new IntegerOutput<>(codec), args); + } + + RedisCommand zlexcount(K key, String min, String max) { + notNullKey(key); + notNullMinMax(min, max); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(min).add(max); + return createCommand(ZLEXCOUNT, new IntegerOutput<>(codec), args); + } + + RedisCommand zlexcount(K key, Range range) { + notNullKey(key); + notNullRange(range); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(minValue(range)).add(maxValue(range)); + return createCommand(ZLEXCOUNT, new IntegerOutput<>(codec), args); + } + + Command> zrange(K key, long start, long stop) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(ZRANGE, new ValueListOutput<>(codec), args); + } + + Command zrange(ValueStreamingChannel channel, K key, long start, long stop) { + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(ZRANGE, new ValueStreamingOutput<>(codec, channel), args); } - public Command> zrange(K key, long start, long stop) { + Command>> zrangeWithScores(K key, long start, long stop) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(ZRANGE, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(start).add(stop).add(WITHSCORES); + return createCommand(ZRANGE, new ScoredValueListOutput<>(codec), args); } - public Command>> zrangeWithScores(K key, long start, long stop) { + Command zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { notNullKey(key); + notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(start).add(stop).add(WITHSCORES); - return createCommand(ZRANGE, new ScoredValueListOutput(codec), args); + return createCommand(ZRANGE, new ScoredValueStreamingOutput<>(codec, channel), args); + } + + RedisCommand> zrangebylex(K key, String min, String max) { + notNullKey(key); + notNullMinMax(min, max); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(min).add(max); + return createCommand(ZRANGEBYLEX, new ValueListOutput<>(codec), args); + } + + RedisCommand> zrangebylex(K key, String min, String max, long offset, long count) { + notNullKey(key); + notNullMinMax(min, max); + + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(min).add(max), Limit.create(offset, count)); + return createCommand(ZRANGEBYLEX, new ValueListOutput<>(codec), args); + } + + RedisCommand> zrangebylex(K key, Range range, Limit limit) { + notNullKey(key); + notNullRange(range); + notNullLimit(limit); + + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(minValue(range)).add(maxValue(range)), limit); + return createCommand(ZRANGEBYLEX, new ValueListOutput<>(codec), args); } - public Command> zrangebyscore(K key, double min, double max) { + Command> zrangebyscore(K key, double min, double max) { return zrangebyscore(key, string(min), string(max)); } - public Command> zrangebyscore(K key, String min, String max) { + Command> zrangebyscore(K key, String min, String max) { notNullKey(key); notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec).addKey(key).add(min).add(max); - return createCommand(ZRANGEBYSCORE, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(min).add(max); + return createCommand(ZRANGEBYSCORE, new ValueListOutput<>(codec), args); } - public Command> zrangebyscore(K key, double min, double max, long offset, long count) { + Command> zrangebyscore(K key, double min, double max, long offset, long count) { return zrangebyscore(key, string(min), string(max), offset, count); } - public Command> zrangebyscore(K key, String min, String max, long offset, long count) { + Command> zrangebyscore(K key, String min, String max, long offset, long count) { notNullKey(key); notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(min).add(max).add(LIMIT).add(offset).add(count); - return createCommand(ZRANGEBYSCORE, new ValueListOutput(codec), args); + return createCommand(ZRANGEBYSCORE, new ValueListOutput<>(codec), args); } - public Command> zrangebyscore(K key, Range range, Limit limit) { + Command> zrangebyscore(K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(min(range)).add(max(range)); if (limit.isLimited()) { args.add(LIMIT).add(limit.getOffset()).add(limit.getCount()); } - return createCommand(ZRANGEBYSCORE, new ValueListOutput(codec), args); + return createCommand(ZRANGEBYSCORE, new ValueListOutput<>(codec), args); } - public Command>> zrangebyscoreWithScores(K key, double min, double max) { - return zrangebyscoreWithScores(key, string(min), string(max)); + Command zrangebyscore(ValueStreamingChannel channel, K key, double min, double max) { + return zrangebyscore(channel, key, string(min), string(max)); } - public Command>> zrangebyscoreWithScores(K key, String min, String max) { + Command zrangebyscore(ValueStreamingChannel channel, K key, String min, String max) { notNullKey(key); notNullMinMax(min, max); + LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(min).add(max).add(WITHSCORES); - return createCommand(ZRANGEBYSCORE, new ScoredValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(min).add(max); + return createCommand(ZRANGEBYSCORE, new ValueStreamingOutput<>(codec, channel), args); } - public Command>> zrangebyscoreWithScores(K key, double min, double max, long offset, long count) { - return zrangebyscoreWithScores(key, string(min), string(max), offset, count); + Command zrangebyscore(ValueStreamingChannel channel, K key, double min, double max, long offset, + long count) { + return zrangebyscore(channel, key, string(min), string(max), offset, count); } - public Command>> zrangebyscoreWithScores(K key, String min, String max, long offset, long count) { + Command zrangebyscore(ValueStreamingChannel channel, K key, String min, String max, long offset, + long count) { notNullKey(key); notNullMinMax(min, max); + LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(min).add(max).add(WITHSCORES), Limit.create(offset, count)); - return createCommand(ZRANGEBYSCORE, new ScoredValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(min).add(max), Limit.create(offset, count)); + return createCommand(ZRANGEBYSCORE, new ValueStreamingOutput<>(codec, channel), args); } - public Command>> zrangebyscoreWithScores(K key, Range range, Limit limit) { + Command zrangebyscore(ValueStreamingChannel channel, K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); + LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(min(range)).add(max(range)).add(WITHSCORES), limit); - return createCommand(ZRANGEBYSCORE, new ScoredValueListOutput(codec), args); - } - - public Command zrange(ValueStreamingChannel channel, K key, long start, long stop) { - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(ZRANGE, new ValueStreamingOutput(codec, channel), args); - } - - public Command zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { - notNullKey(key); - notNull(channel); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(start).add(stop).add(WITHSCORES); - return createCommand(ZRANGE, new ScoredValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(min(range)).add(max(range)), limit); + return createCommand(ZRANGEBYSCORE, new ValueStreamingOutput<>(codec, channel), args); } - public Command zrangebyscore(ValueStreamingChannel channel, K key, double min, double max) { - return zrangebyscore(channel, key, string(min), string(max)); + Command>> zrangebyscoreWithScores(K key, double min, double max) { + return zrangebyscoreWithScores(key, string(min), string(max)); } - public Command zrangebyscore(ValueStreamingChannel channel, K key, String min, String max) { + Command>> zrangebyscoreWithScores(K key, String min, String max) { notNullKey(key); notNullMinMax(min, max); - LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).add(min).add(max); - return createCommand(ZRANGEBYSCORE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(min).add(max).add(WITHSCORES); + return createCommand(ZRANGEBYSCORE, new ScoredValueListOutput<>(codec), args); } - public Command zrangebyscore(ValueStreamingChannel channel, K key, double min, double max, long offset, - long count) { - return zrangebyscore(channel, key, string(min), string(max), offset, count); + Command>> zrangebyscoreWithScores(K key, double min, double max, long offset, long count) { + return zrangebyscoreWithScores(key, string(min), string(max), offset, count); } - public Command zrangebyscore(ValueStreamingChannel channel, K key, String min, String max, long offset, - long count) { + Command>> zrangebyscoreWithScores(K key, String min, String max, long offset, long count) { notNullKey(key); notNullMinMax(min, max); - LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(min).add(max), Limit.create(offset, count)); - return createCommand(ZRANGEBYSCORE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(min).add(max).add(WITHSCORES), Limit.create(offset, count)); + return createCommand(ZRANGEBYSCORE, new ScoredValueListOutput<>(codec), args); } - public Command zrangebyscore(ValueStreamingChannel channel, K key, Range range, Limit limit) { + Command>> zrangebyscoreWithScores(K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); - LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(min(range)).add(max(range)), limit); - return createCommand(ZRANGEBYSCORE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(min(range)).add(max(range)).add(WITHSCORES), limit); + return createCommand(ZRANGEBYSCORE, new ScoredValueListOutput<>(codec), args); } - public Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max) { + Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max) { return zrangebyscoreWithScores(channel, key, string(min), string(max)); } - public Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max) { + Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max) { notNullKey(key); notNullMinMax(min, max); notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(min).add(max).add(WITHSCORES); - return createCommand(ZRANGEBYSCORE, new ScoredValueStreamingOutput(codec, channel), args); + return createCommand(ZRANGEBYSCORE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max, + Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max, long offset, long count) { return zrangebyscoreWithScores(channel, key, string(min), string(max), offset, count); } - public Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max, + Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max, long offset, long count) { notNullKey(key); notNullMinMax(min, max); notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); addLimit(args.addKey(key).add(min).add(max).add(WITHSCORES), Limit.create(offset, count)); - return createCommand(ZRANGEBYSCORE, new ScoredValueStreamingOutput(codec, channel), args); + return createCommand(ZRANGEBYSCORE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Command zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); addLimit(args.addKey(key).add(min(range)).add(max(range)).add(WITHSCORES), limit); - return createCommand(ZRANGEBYSCORE, new ScoredValueStreamingOutput(codec, channel), args); + return createCommand(ZRANGEBYSCORE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command zrank(K key, V member) { + Command zrank(K key, V member) { notNullKey(key); - return createCommand(ZRANK, new IntegerOutput(codec), key, member); + return createCommand(ZRANK, new IntegerOutput<>(codec), key, member); } - public Command zrem(K key, V... members) { + Command zrem(K key, V... members) { notNullKey(key); LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); - return createCommand(ZREM, new IntegerOutput(codec), key, members); + return createCommand(ZREM, new IntegerOutput<>(codec), key, members); + } + + RedisCommand zremrangebylex(K key, String min, String max) { + notNullKey(key); + notNullMinMax(min, max); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(min).add(max); + return createCommand(ZREMRANGEBYLEX, new IntegerOutput<>(codec), args); + } + + RedisCommand zremrangebylex(K key, Range range) { + notNullKey(key); + notNullRange(range); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(minValue(range)).add(maxValue(range)); + return createCommand(ZREMRANGEBYLEX, new IntegerOutput<>(codec), args); } - public Command zremrangebyrank(K key, long start, long stop) { + Command zremrangebyrank(K key, long start, long stop) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(ZREMRANGEBYRANK, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(ZREMRANGEBYRANK, new IntegerOutput<>(codec), args); } - public Command zremrangebyscore(K key, double min, double max) { + Command zremrangebyscore(K key, double min, double max) { return zremrangebyscore(key, string(min), string(max)); } - public Command zremrangebyscore(K key, String min, String max) { + Command zremrangebyscore(K key, String min, String max) { notNullKey(key); notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec).addKey(key).add(min).add(max); - return createCommand(ZREMRANGEBYSCORE, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(min).add(max); + return createCommand(ZREMRANGEBYSCORE, new IntegerOutput<>(codec), args); } - public Command zremrangebyscore(K key, Range range) { + Command zremrangebyscore(K key, Range range) { notNullKey(key); notNullRange(range); - CommandArgs args = new CommandArgs(codec).addKey(key).add(min(range)).add(max(range)); - return createCommand(ZREMRANGEBYSCORE, new IntegerOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(min(range)).add(max(range)); + return createCommand(ZREMRANGEBYSCORE, new IntegerOutput<>(codec), args); } - public Command> zrevrange(K key, long start, long stop) { + Command> zrevrange(K key, long start, long stop) { notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(ZREVRANGE, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(ZREVRANGE, new ValueListOutput<>(codec), args); } - public Command> zrevrangebylex(K key, Range range, Limit limit) { + Command zrevrange(ValueStreamingChannel channel, K key, long start, long stop) { notNullKey(key); - notNullRange(range); - notNullLimit(limit); + notNull(channel); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(maxValue(range)).add(minValue(range)), limit); - return createCommand(ZREVRANGEBYLEX, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(start).add(stop); + return createCommand(ZREVRANGE, new ValueStreamingOutput<>(codec, channel), args); + } + + Command>> zrevrangeWithScores(K key, long start, long stop) { + notNullKey(key); + + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(start).add(stop).add(WITHSCORES); + return createCommand(ZREVRANGE, new ScoredValueListOutput<>(codec), args); } - public Command>> zrevrangeWithScores(K key, long start, long stop) { + Command zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { notNullKey(key); + LettuceAssert.notNull(channel, "ValueStreamingChannel " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(start).add(stop).add(WITHSCORES); - return createCommand(ZREVRANGE, new ScoredValueListOutput(codec), args); + return createCommand(ZREVRANGE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command> zrevrangebyscore(K key, double max, double min) { + Command> zrevrangebylex(K key, Range range, Limit limit) { + notNullKey(key); + notNullRange(range); + notNullLimit(limit); + + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(maxValue(range)).add(minValue(range)), limit); + return createCommand(ZREVRANGEBYLEX, new ValueListOutput<>(codec), args); + } + + Command> zrevrangebyscore(K key, double max, double min) { return zrevrangebyscore(key, string(max), string(min)); } - public Command> zrevrangebyscore(K key, String max, String min) { + Command> zrevrangebyscore(K key, String max, String min) { notNullKey(key); notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec).addKey(key).add(max).add(min); - return createCommand(ZREVRANGEBYSCORE, new ValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(max).add(min); + return createCommand(ZREVRANGEBYSCORE, new ValueListOutput<>(codec), args); } - public Command> zrevrangebyscore(K key, double max, double min, long offset, long count) { + Command> zrevrangebyscore(K key, double max, double min, long offset, long count) { return zrevrangebyscore(key, string(max), string(min), offset, count); } - public Command> zrevrangebyscore(K key, String max, String min, long offset, long count) { + Command> zrevrangebyscore(K key, String max, String min, long offset, long count) { notNullKey(key); notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); addLimit(args.addKey(key).add(max).add(min), Limit.create(offset, count)); - return createCommand(ZREVRANGEBYSCORE, new ValueListOutput(codec), args); + return createCommand(ZREVRANGEBYSCORE, new ValueListOutput<>(codec), args); } - public Command> zrevrangebyscore(K key, Range range, Limit limit) { + Command> zrevrangebyscore(K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); addLimit(args.addKey(key).add(max(range)).add(min(range)), limit); - return createCommand(ZREVRANGEBYSCORE, new ValueListOutput(codec), args); + return createCommand(ZREVRANGEBYSCORE, new ValueListOutput<>(codec), args); } - public Command>> zrevrangebyscoreWithScores(K key, double max, double min) { - return zrevrangebyscoreWithScores(key, string(max), string(min)); + Command zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min) { + return zrevrangebyscore(channel, key, string(max), string(min)); } - public Command>> zrevrangebyscoreWithScores(K key, String max, String min) { + Command zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min) { notNullKey(key); notNullMinMax(min, max); + notNull(channel); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(max).add(min).add(WITHSCORES); - return createCommand(ZREVRANGEBYSCORE, new ScoredValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec).addKey(key).add(max).add(min); + return createCommand(ZREVRANGEBYSCORE, new ValueStreamingOutput<>(codec, channel), args); } - public Command>> zrevrangebyscoreWithScores(K key, double max, double min, long offset, long count) { - return zrevrangebyscoreWithScores(key, string(max), string(min), offset, count); + Command zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min, long offset, + long count) { + return zrevrangebyscore(channel, key, string(max), string(min), offset, count); } - public Command>> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count) { + Command zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min, long offset, + long count) { notNullKey(key); notNullMinMax(min, max); + notNull(channel); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(max).add(min).add(WITHSCORES), Limit.create(offset, count)); - return createCommand(ZREVRANGEBYSCORE, new ScoredValueListOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(max).add(min), Limit.create(offset, count)); + return createCommand(ZREVRANGEBYSCORE, new ValueStreamingOutput<>(codec, channel), args); } - public Command>> zrevrangebyscoreWithScores(K key, Range range, Limit limit) { + Command zrevrangebyscore(ValueStreamingChannel channel, K key, Range range, + Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); - - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(max(range)).add(min(range)).add(WITHSCORES), limit); - return createCommand(ZREVRANGEBYSCORE, new ScoredValueListOutput(codec), args); - } - - public Command zrevrange(ValueStreamingChannel channel, K key, long start, long stop) { - notNullKey(key); notNull(channel); - CommandArgs args = new CommandArgs(codec).addKey(key).add(start).add(stop); - return createCommand(ZREVRANGE, new ValueStreamingOutput(codec, channel), args); - } - - public Command zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop) { - notNullKey(key); - LettuceAssert.notNull(channel, "ValueStreamingChannel " + MUST_NOT_BE_NULL); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(start).add(stop).add(WITHSCORES); - return createCommand(ZREVRANGE, new ScoredValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(max(range)).add(min(range)), limit); + return createCommand(ZREVRANGEBYSCORE, new ValueStreamingOutput<>(codec, channel), args); } - public Command zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min) { - return zrevrangebyscore(channel, key, string(max), string(min)); + Command>> zrevrangebyscoreWithScores(K key, double max, double min) { + return zrevrangebyscoreWithScores(key, string(max), string(min)); } - public Command zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min) { + Command>> zrevrangebyscoreWithScores(K key, String max, String min) { notNullKey(key); notNullMinMax(min, max); - notNull(channel); - CommandArgs args = new CommandArgs(codec).addKey(key).add(max).add(min); - return createCommand(ZREVRANGEBYSCORE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key).add(max).add(min).add(WITHSCORES); + return createCommand(ZREVRANGEBYSCORE, new ScoredValueListOutput<>(codec), args); } - public Command zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min, long offset, - long count) { - return zrevrangebyscore(channel, key, string(max), string(min), offset, count); + Command>> zrevrangebyscoreWithScores(K key, double max, double min, long offset, long count) { + return zrevrangebyscoreWithScores(key, string(max), string(min), offset, count); } - public Command zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min, long offset, - long count) { + Command>> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count) { notNullKey(key); notNullMinMax(min, max); - notNull(channel); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(max).add(min), Limit.create(offset, count)); - return createCommand(ZREVRANGEBYSCORE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(max).add(min).add(WITHSCORES), Limit.create(offset, count)); + return createCommand(ZREVRANGEBYSCORE, new ScoredValueListOutput<>(codec), args); } - public Command zrevrangebyscore(ValueStreamingChannel channel, K key, Range range, - Limit limit) { + Command>> zrevrangebyscoreWithScores(K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); - notNull(channel); - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(max(range)).add(min(range)), limit); - return createCommand(ZREVRANGEBYSCORE, new ValueStreamingOutput(codec, channel), args); + CommandArgs args = new CommandArgs<>(codec); + addLimit(args.addKey(key).add(max(range)).add(min(range)).add(WITHSCORES), limit); + return createCommand(ZREVRANGEBYSCORE, new ScoredValueListOutput<>(codec), args); } - public Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min) { + Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min) { return zrevrangebyscoreWithScores(channel, key, string(max), string(min)); } - public Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min) { + Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min) { notNullKey(key); notNullMinMax(min, max); notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); args.addKey(key).add(max).add(min).add(WITHSCORES); - return createCommand(ZREVRANGEBYSCORE, new ScoredValueStreamingOutput(codec, channel), args); + return createCommand(ZREVRANGEBYSCORE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, + Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min, long offset, long count) { notNullKey(key); LettuceAssert.notNull(min, "Min " + MUST_NOT_BE_NULL); @@ -1923,811 +2544,184 @@ public Command zrevrangebyscoreWithScores(ScoredValueStreamingChanne return zrevrangebyscoreWithScores(channel, key, string(max), string(min), offset, count); } - public Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, + Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min, long offset, long count) { notNullKey(key); notNullMinMax(min, max); notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); addLimit(args.addKey(key).add(max).add(min).add(WITHSCORES), Limit.create(offset, count)); - return createCommand(ZREVRANGEBYSCORE, new ScoredValueStreamingOutput(codec, channel), args); + return createCommand(ZREVRANGEBYSCORE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, + Command zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, Range range, Limit limit) { notNullKey(key); notNullRange(range); notNullLimit(limit); notNull(channel); - CommandArgs args = new CommandArgs(codec); + CommandArgs args = new CommandArgs<>(codec); addLimit(args.addKey(key).add(max(range)).add(min(range)).add(WITHSCORES), limit); - return createCommand(ZREVRANGEBYSCORE, new ScoredValueStreamingOutput(codec, channel), args); + return createCommand(ZREVRANGEBYSCORE, new ScoredValueStreamingOutput<>(codec, channel), args); } - public Command zrevrank(K key, V member) { + Command zrevrank(K key, V member) { notNullKey(key); - return createCommand(ZREVRANK, new IntegerOutput(codec), key, member); + return createCommand(ZREVRANK, new IntegerOutput<>(codec), key, member); } - public Command zscore(K key, V member) { + Command> zscan(K key) { notNullKey(key); - return createCommand(ZSCORE, new DoubleOutput(codec), key, member); + return zscan(key, ScanCursor.INITIAL, null); } - public Command zunionstore(K destination, K... keys) { - notEmpty(keys); - LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); + Command> zscan(K key, ScanCursor scanCursor) { + notNullKey(key); - return zunionstore(destination, new ZStoreArgs(), keys); + return zscan(key, scanCursor, null); } - public Command zunionstore(K destination, ZStoreArgs storeArgs, K... keys) { - notEmpty(keys); + Command> zscan(K key, ScanArgs scanArgs) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec); - args.addKey(destination).add(keys.length).addKeys(keys); - storeArgs.build(args); - return createCommand(ZUNIONSTORE, new IntegerOutput(codec), args); + return zscan(key, ScanCursor.INITIAL, scanArgs); } - public RedisCommand zlexcount(K key, String min, String max) { + Command> zscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { notNullKey(key); - notNullMinMax(min, max); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(min).add(max); - return createCommand(ZLEXCOUNT, new IntegerOutput(codec), args); - } + CommandArgs args = new CommandArgs<>(codec); + args.addKey(key); - public RedisCommand zlexcount(K key, Range range) { - notNullKey(key); - notNullRange(range); + scanArgs(scanCursor, scanArgs, args); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(minValue(range)).add(maxValue(range)); - return createCommand(ZLEXCOUNT, new IntegerOutput(codec), args); + ScoredValueScanOutput output = new ScoredValueScanOutput<>(codec); + return createCommand(ZSCAN, output, args); } - public RedisCommand zremrangebylex(K key, String min, String max) { + Command zscanStreaming(ScoredValueStreamingChannel channel, K key) { notNullKey(key); - notNullMinMax(min, max); + notNull(channel); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(min).add(max); - return createCommand(ZREMRANGEBYLEX, new IntegerOutput(codec), args); + return zscanStreaming(channel, key, ScanCursor.INITIAL, null); } - public RedisCommand zremrangebylex(K key, Range range) { + Command zscanStreaming(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor) { notNullKey(key); - notNullRange(range); + notNull(channel); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(minValue(range)).add(maxValue(range)); - return createCommand(ZREMRANGEBYLEX, new IntegerOutput(codec), args); + return zscanStreaming(channel, key, scanCursor, null); } - public RedisCommand> zrangebylex(K key, String min, String max) { + Command zscanStreaming(ScoredValueStreamingChannel channel, K key, ScanArgs scanArgs) { notNullKey(key); - notNullMinMax(min, max); + notNull(channel); - CommandArgs args = new CommandArgs(codec); - args.addKey(key).add(min).add(max); - return createCommand(ZRANGEBYLEX, new ValueListOutput(codec), args); + return zscanStreaming(channel, key, ScanCursor.INITIAL, scanArgs); } - public RedisCommand> zrangebylex(K key, String min, String max, long offset, long count) { + Command zscanStreaming(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor, + ScanArgs scanArgs) { notNullKey(key); - notNullMinMax(min, max); - - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(min).add(max), Limit.create(offset, count)); - return createCommand(ZRANGEBYLEX, new ValueListOutput(codec), args); - } - - public RedisCommand> zrangebylex(K key, Range range, Limit limit) { - notNullKey(key); - notNullRange(range); - notNullLimit(limit); - - CommandArgs args = new CommandArgs(codec); - addLimit(args.addKey(key).add(minValue(range)).add(maxValue(range)), limit); - return createCommand(ZRANGEBYLEX, new ValueListOutput(codec), args); - } - - public Command> time() { - CommandArgs args = new CommandArgs(codec); - return createCommand(TIME, new ValueListOutput(codec), args); - } - - public Command> scan() { - return scan(ScanCursor.INITIAL, null); - } - - public Command> scan(ScanCursor scanCursor) { - return scan(scanCursor, null); - } - - public Command> scan(ScanArgs scanArgs) { - return scan(ScanCursor.INITIAL, scanArgs); - } - - public Command> scan(ScanCursor scanCursor, ScanArgs scanArgs) { - CommandArgs args = new CommandArgs(codec); - - scanArgs(scanCursor, scanArgs, args); - - KeyScanOutput output = new KeyScanOutput(codec); - return createCommand(SCAN, output, args); - } - - protected void scanArgs(ScanCursor scanCursor, ScanArgs scanArgs, CommandArgs args) { - LettuceAssert.notNull(scanCursor, "ScanCursor " + MUST_NOT_BE_NULL); - LettuceAssert.isTrue(!scanCursor.isFinished(), "ScanCursor must not be finished"); - - args.add(scanCursor.getCursor()); - - if (scanArgs != null) { - scanArgs.build(args); - } - } - - public Command scanStreaming(KeyStreamingChannel channel) { - notNull(channel); - LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); - - return scanStreaming(channel, ScanCursor.INITIAL, null); - } - - public Command scanStreaming(KeyStreamingChannel channel, ScanCursor scanCursor) { - notNull(channel); - LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); - - return scanStreaming(channel, scanCursor, null); - } - - public Command scanStreaming(KeyStreamingChannel channel, ScanArgs scanArgs) { - notNull(channel); - LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); - - return scanStreaming(channel, ScanCursor.INITIAL, scanArgs); - } - - public Command scanStreaming(KeyStreamingChannel channel, ScanCursor scanCursor, - ScanArgs scanArgs) { - notNull(channel); - LettuceAssert.notNull(channel, "KeyStreamingChannel " + MUST_NOT_BE_NULL); - - CommandArgs args = new CommandArgs(codec); - scanArgs(scanCursor, scanArgs, args); - - KeyScanStreamingOutput output = new KeyScanStreamingOutput(codec, channel); - return createCommand(SCAN, output, args); - } - - public Command> sscan(K key) { - notNullKey(key); - - return sscan(key, ScanCursor.INITIAL, null); - } - - public Command> sscan(K key, ScanCursor scanCursor) { - notNullKey(key); - - return sscan(key, scanCursor, null); - } - - public Command> sscan(K key, ScanArgs scanArgs) { - notNullKey(key); - - return sscan(key, ScanCursor.INITIAL, scanArgs); - } - - public Command> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key); - - scanArgs(scanCursor, scanArgs, args); - - ValueScanOutput output = new ValueScanOutput(codec); - return createCommand(SSCAN, output, args); - } - - public Command sscanStreaming(ValueStreamingChannel channel, K key) { - notNullKey(key); - notNull(channel); - - return sscanStreaming(channel, key, ScanCursor.INITIAL, null); - } - - public Command sscanStreaming(ValueStreamingChannel channel, K key, ScanCursor scanCursor) { - notNullKey(key); - notNull(channel); - - return sscanStreaming(channel, key, scanCursor, null); - } - - public Command sscanStreaming(ValueStreamingChannel channel, K key, ScanArgs scanArgs) { - notNullKey(key); - notNull(channel); - - return sscanStreaming(channel, key, ScanCursor.INITIAL, scanArgs); - } - - public Command sscanStreaming(ValueStreamingChannel channel, K key, ScanCursor scanCursor, - ScanArgs scanArgs) { - notNullKey(key); - notNull(channel); - - CommandArgs args = new CommandArgs(codec); - - args.addKey(key); - scanArgs(scanCursor, scanArgs, args); - - ValueScanStreamingOutput output = new ValueScanStreamingOutput(codec, channel); - return createCommand(SSCAN, output, args); - } - - public Command> hscan(K key) { - notNullKey(key); - - return hscan(key, ScanCursor.INITIAL, null); - } - - public Command> hscan(K key, ScanCursor scanCursor) { - notNullKey(key); - - return hscan(key, scanCursor, null); - } - - public Command> hscan(K key, ScanArgs scanArgs) { - notNullKey(key); - - return hscan(key, ScanCursor.INITIAL, scanArgs); - } - - public Command> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key); - - scanArgs(scanCursor, scanArgs, args); - - MapScanOutput output = new MapScanOutput(codec); - return createCommand(HSCAN, output, args); - } - - public Command hscanStreaming(KeyValueStreamingChannel channel, K key) { - notNullKey(key); - notNull(channel); - - return hscanStreaming(channel, key, ScanCursor.INITIAL, null); - } - - public Command hscanStreaming(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor) { - notNullKey(key); - notNull(channel); - - return hscanStreaming(channel, key, scanCursor, null); - } - - public Command hscanStreaming(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs) { - notNullKey(key); - notNull(channel); - - return hscanStreaming(channel, key, ScanCursor.INITIAL, scanArgs); - } - - public Command hscanStreaming(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, - ScanArgs scanArgs) { - notNullKey(key); - notNull(channel); - - CommandArgs args = new CommandArgs(codec); - - args.addKey(key); - scanArgs(scanCursor, scanArgs, args); - - KeyValueScanStreamingOutput output = new KeyValueScanStreamingOutput(codec, channel); - return createCommand(HSCAN, output, args); - } - - public Command> zscan(K key) { - notNullKey(key); - - return zscan(key, ScanCursor.INITIAL, null); - } - - public Command> zscan(K key, ScanCursor scanCursor) { - notNullKey(key); - - return zscan(key, scanCursor, null); - } - - public Command> zscan(K key, ScanArgs scanArgs) { - notNullKey(key); - - return zscan(key, ScanCursor.INITIAL, scanArgs); - } - - public Command> zscan(K key, ScanCursor scanCursor, ScanArgs scanArgs) { - notNullKey(key); - - CommandArgs args = new CommandArgs(codec); - args.addKey(key); - - scanArgs(scanCursor, scanArgs, args); - - ScoredValueScanOutput output = new ScoredValueScanOutput(codec); - return createCommand(ZSCAN, output, args); - } - - public Command zscanStreaming(ScoredValueStreamingChannel channel, K key) { - notNullKey(key); - notNull(channel); - - return zscanStreaming(channel, key, ScanCursor.INITIAL, null); - } - - public Command zscanStreaming(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor) { - notNullKey(key); - notNull(channel); - - return zscanStreaming(channel, key, scanCursor, null); - } - - public Command zscanStreaming(ScoredValueStreamingChannel channel, K key, ScanArgs scanArgs) { - notNullKey(key); - notNull(channel); - - return zscanStreaming(channel, key, ScanCursor.INITIAL, scanArgs); - } - - public Command zscanStreaming(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor, - ScanArgs scanArgs) { - notNullKey(key); - notNull(channel); - - CommandArgs args = new CommandArgs(codec); - - args.addKey(key); - scanArgs(scanCursor, scanArgs, args); - - ScoredValueScanStreamingOutput output = new ScoredValueScanStreamingOutput(codec, channel); - return createCommand(ZSCAN, output, args); - } - - public Command pfadd(K key, V value, V... moreValues) { - notNullKey(key); - LettuceAssert.notNull(value, "Value " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(moreValues, "MoreValues " + MUST_NOT_BE_NULL); - LettuceAssert.noNullElements(moreValues, "MoreValues " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - - CommandArgs args = new CommandArgs(codec).addKey(key).addValue(value).addValues(moreValues); - return createCommand(PFADD, new IntegerOutput(codec), args); - } - - public Command pfadd(K key, V... values) { - notNullKey(key); - notEmptyValues(values); - LettuceAssert.noNullElements(values, "Values " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - - CommandArgs args = new CommandArgs(codec).addKey(key).addValues(values); - return createCommand(PFADD, new IntegerOutput(codec), args); - } - - public Command pfcount(K key, K... moreKeys) { - notNullKey(key); - LettuceAssert.notNull(moreKeys, "MoreKeys " + MUST_NOT_BE_NULL); - LettuceAssert.noNullElements(moreKeys, "MoreKeys " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - - CommandArgs args = new CommandArgs(codec).addKey(key).addKeys(moreKeys); - return createCommand(PFCOUNT, new IntegerOutput(codec), args); - } - - public Command pfcount(K... keys) { - notEmpty(keys); - - CommandArgs args = new CommandArgs(codec).addKeys(keys); - return createCommand(PFCOUNT, new IntegerOutput(codec), args); - } - - @SuppressWarnings("unchecked") - public Command pfmerge(K destkey, K sourcekey, K... moreSourceKeys) { - LettuceAssert.notNull(destkey, "Destkey " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(sourcekey, "Sourcekey " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(moreSourceKeys, "MoreSourceKeys " + MUST_NOT_BE_NULL); - LettuceAssert.noNullElements(moreSourceKeys, "MoreSourceKeys " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - - CommandArgs args = new CommandArgs(codec).addKeys(destkey).addKey(sourcekey).addKeys(moreSourceKeys); - return createCommand(PFMERGE, new StatusOutput(codec), args); - } - - @SuppressWarnings("unchecked") - public Command pfmerge(K destkey, K... sourcekeys) { - LettuceAssert.notNull(destkey, "Destkey " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(sourcekeys, "Sourcekeys " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(sourcekeys, "Sourcekeys " + MUST_NOT_BE_EMPTY); - LettuceAssert.noNullElements(sourcekeys, "Sourcekeys " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - - CommandArgs args = new CommandArgs(codec).addKeys(destkey).addKeys(sourcekeys); - return createCommand(PFMERGE, new StatusOutput(codec), args); - } - - public Command clusterBumpepoch() { - CommandArgs args = new CommandArgs(codec).add(BUMPEPOCH); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterMeet(String ip, int port) { - LettuceAssert.notNull(ip, "IP " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(ip, "IP " + MUST_NOT_BE_EMPTY); - - CommandArgs args = new CommandArgs(codec).add(MEET).add(ip).add(port); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterForget(String nodeId) { - assertNodeId(nodeId); - - CommandArgs args = new CommandArgs(codec).add(FORGET).add(nodeId); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterAddslots(int[] slots) { - notEmptySlots(slots); - - CommandArgs args = new CommandArgs(codec).add(ADDSLOTS); - - for (int slot : slots) { - args.add(slot); - } - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterDelslots(int[] slots) { - notEmptySlots(slots); - - CommandArgs args = new CommandArgs(codec).add(DELSLOTS); - - for (int slot : slots) { - args.add(slot); - } - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterInfo() { - CommandArgs args = new CommandArgs(codec).add(INFO); - - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterMyId() { - CommandArgs args = new CommandArgs(codec).add(MYID); - - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterNodes() { - CommandArgs args = new CommandArgs(codec).add(NODES); - - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command> clusterGetKeysInSlot(int slot, int count) { - CommandArgs args = new CommandArgs(codec).add(GETKEYSINSLOT).add(slot).add(count); - return createCommand(CLUSTER, new KeyListOutput(codec), args); - } - - public Command clusterCountKeysInSlot(int slot) { - CommandArgs args = new CommandArgs(codec).add(COUNTKEYSINSLOT).add(slot); - return createCommand(CLUSTER, new IntegerOutput(codec), args); - } - - public Command clusterCountFailureReports(String nodeId) { - assertNodeId(nodeId); - - CommandArgs args = new CommandArgs(codec).add("COUNT-FAILURE-REPORTS").add(nodeId); - return createCommand(CLUSTER, new IntegerOutput(codec), args); - } - - public Command clusterKeyslot(K key) { - CommandArgs args = new CommandArgs(codec).add(KEYSLOT).addKey(key); - return createCommand(CLUSTER, new IntegerOutput(codec), args); - } - - public Command clusterSaveconfig() { - CommandArgs args = new CommandArgs(codec).add(SAVECONFIG); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterSetConfigEpoch(long configEpoch) { - CommandArgs args = new CommandArgs(codec).add("SET-CONFIG-EPOCH").add(configEpoch); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command> clusterSlots() { - CommandArgs args = new CommandArgs(codec).add(SLOTS); - return createCommand(CLUSTER, new ArrayOutput(codec), args); - } - - public Command clusterSetSlotNode(int slot, String nodeId) { - assertNodeId(nodeId); - - CommandArgs args = new CommandArgs(codec).add(SETSLOT).add(slot).add(NODE).add(nodeId); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterSetSlotStable(int slot) { - - CommandArgs args = new CommandArgs(codec).add(SETSLOT).add(slot).add(STABLE); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterSetSlotMigrating(int slot, String nodeId) { - assertNodeId(nodeId); - - CommandArgs args = new CommandArgs(codec).add(SETSLOT).add(slot).add(MIGRATING).add(nodeId); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterSetSlotImporting(int slot, String nodeId) { - assertNodeId(nodeId); - - CommandArgs args = new CommandArgs(codec).add(SETSLOT).add(slot).add(IMPORTING).add(nodeId); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command clusterReplicate(String nodeId) { - assertNodeId(nodeId); + notNull(channel); - CommandArgs args = new CommandArgs(codec).add(REPLICATE).add(nodeId); - return createCommand(CLUSTER, new StatusOutput(codec), args); - } + CommandArgs args = new CommandArgs<>(codec); - public Command asking() { + args.addKey(key); + scanArgs(scanCursor, scanArgs, args); - CommandArgs args = new CommandArgs(codec); - return createCommand(ASKING, new StatusOutput(codec), args); + ScoredValueScanStreamingOutput output = new ScoredValueScanStreamingOutput<>(codec, channel); + return createCommand(ZSCAN, output, args); } - public Command clusterFlushslots() { + Command zscore(K key, V member) { + notNullKey(key); - CommandArgs args = new CommandArgs(codec).add(FLUSHSLOTS); - return createCommand(CLUSTER, new StatusOutput(codec), args); + return createCommand(ZSCORE, new DoubleOutput<>(codec), key, member); } - public Command> clusterSlaves(String nodeId) { - assertNodeId(nodeId); + Command zunionstore(K destination, K... keys) { + notEmpty(keys); + LettuceAssert.notNull(destination, "Destination " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).add(SLAVES).add(nodeId); - return createCommand(CLUSTER, new StringListOutput(codec), args); + return zunionstore(destination, new ZStoreArgs(), keys); } - public Command clusterFailover(boolean force) { + Command zunionstore(K destination, ZStoreArgs storeArgs, K... keys) { + notEmpty(keys); - CommandArgs args = new CommandArgs(codec).add(FAILOVER); - if (force) { - args.add(FORCE); - } - return createCommand(CLUSTER, new StatusOutput(codec), args); + CommandArgs args = new CommandArgs<>(codec); + args.addKey(destination).add(keys.length).addKeys(keys); + storeArgs.build(args); + return createCommand(ZUNIONSTORE, new IntegerOutput<>(codec), args); } - public Command clusterReset(boolean hard) { + private boolean allElementsInstanceOf(Object[] objects, Class expectedAssignableType) { - CommandArgs args = new CommandArgs(codec).add(RESET); - if (hard) { - args.add(HARD); - } else { - args.add(SOFT); + for (Object object : objects) { + if (!expectedAssignableType.isAssignableFrom(object.getClass())) { + return false; + } } - return createCommand(CLUSTER, new StatusOutput(codec), args); - } - - public Command geoadd(K key, double longitude, double latitude, V member) { - notNullKey(key); - CommandArgs args = new CommandArgs(codec).addKey(key).add(longitude).add(latitude).addValue(member); - return createCommand(GEOADD, new IntegerOutput(codec), args); + return true; } - public Command geoadd(K key, Object[] lngLatMember) { - - notNullKey(key); - LettuceAssert.notNull(lngLatMember, "LngLatMember " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(lngLatMember, "LngLatMember " + MUST_NOT_BE_EMPTY); - LettuceAssert.noNullElements(lngLatMember, "LngLatMember " + MUST_NOT_CONTAIN_NULL_ELEMENTS); - LettuceAssert - .isTrue(lngLatMember.length % 3 == 0, - "LngLatMember.length must be a multiple of 3 and contain a " - + "sequence of longitude1, latitude1, member1, longitude2, latitude2, member2, ... longitudeN, latitudeN, memberN"); + private byte[] maxValue(Range range) { - CommandArgs args = new CommandArgs(codec).addKey(key); + Range.Boundary upper = range.getUpper(); - for (int i = 0; i < lngLatMember.length; i += 3) { - args.add((Double) lngLatMember[i]); - args.add((Double) lngLatMember[i + 1]); - args.addValue((V) lngLatMember[i + 2]); + if (upper.getValue() == null) { + return PLUS_BYTES; } - return createCommand(GEOADD, new IntegerOutput(codec), args); - } - - public Command> geohash(K key, V... members) { - notNullKey(key); - LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); - - CommandArgs args = new CommandArgs(codec).addKey(key).addValues(members); - return createCommand(GEOHASH, new StringListOutput(codec), args); - } - - public Command> georadius(CommandType commandType, K key, double longitude, double latitude, double distance, - String unit) { - notNullKey(key); - LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - - CommandArgs args = new CommandArgs(codec).addKey(key).add(longitude).add(latitude).add(distance).add(unit); - return createCommand(commandType, new ValueSetOutput(codec), args); - } - - public Command>> georadius(CommandType commandType, K key, double longitude, double latitude, - double distance, String unit, - GeoArgs geoArgs) { - - notNullKey(key); - LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - LettuceAssert.notNull(geoArgs, "GeoArgs " + MUST_NOT_BE_NULL); - CommandArgs args = new CommandArgs(codec).addKey(key).add(longitude).add(latitude).add(distance).add(unit); - geoArgs.build(args); - - return createCommand(commandType, new GeoWithinListOutput(codec, geoArgs.isWithDistance(), geoArgs.isWithHash(), - geoArgs.isWithCoordinates()), args); - } - - public Command georadius(K key, double longitude, double latitude, double distance, String unit, - GeoRadiusStoreArgs geoRadiusStoreArgs) { - - notNullKey(key); - LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - LettuceAssert.notNull(geoRadiusStoreArgs, "GeoRadiusStoreArgs " + MUST_NOT_BE_NULL); - LettuceAssert.isTrue(geoRadiusStoreArgs.getStoreKey() != null || geoRadiusStoreArgs.getStoreDistKey() != null, - "At least STORE key or STORDIST key is required"); - - CommandArgs args = new CommandArgs(codec).addKey(key).add(longitude).add(latitude).add(distance).add(unit); - geoRadiusStoreArgs.build(args); - - return createCommand(GEORADIUS, new IntegerOutput(codec), args); - } - - public Command> georadiusbymember(CommandType commandType, K key, V member, double distance, String unit) { - - notNullKey(key); - LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - - CommandArgs args = new CommandArgs(codec).addKey(key).addValue(member).add(distance).add(unit); - return createCommand(commandType, new ValueSetOutput(codec), args); - } - - public Command>> georadiusbymember(CommandType commandType, K key, V member, double distance, - String unit, GeoArgs geoArgs) { - - notNullKey(key); - LettuceAssert.notNull(geoArgs, "GeoArgs " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - - CommandArgs args = new CommandArgs(codec).addKey(key).addValue(member).add(distance).add(unit); - geoArgs.build(args); - - return createCommand( -commandType, - new GeoWithinListOutput(codec, geoArgs.isWithDistance(), geoArgs.isWithHash(), geoArgs - .isWithCoordinates()), args); - } - - public Command georadiusbymember(K key, V member, double distance, String unit, - GeoRadiusStoreArgs geoRadiusStoreArgs) { - - notNullKey(key); - LettuceAssert.notNull(geoRadiusStoreArgs, "GeoRadiusStoreArgs " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(unit, "Unit " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(unit, "Unit " + MUST_NOT_BE_EMPTY); - LettuceAssert.isTrue(geoRadiusStoreArgs.getStoreKey() != null || geoRadiusStoreArgs.getStoreDistKey() != null, - "At least STORE key or STORDIST key is required"); - - CommandArgs args = new CommandArgs(codec).addKey(key).addValue(member).add(distance).add(unit); - geoRadiusStoreArgs.build(args); - - return createCommand(GEORADIUSBYMEMBER, new IntegerOutput(codec), args); - } - - public Command> geopos(K key, V[] members) { - notNullKey(key); - LettuceAssert.notNull(members, "Members " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(members, "Members " + MUST_NOT_BE_EMPTY); - CommandArgs args = new CommandArgs(codec).addKey(key).addValues(members); + ByteBuffer encoded = codec.encodeValue(upper.getValue()); + ByteBuffer allocated = ByteBuffer.allocate(encoded.remaining() + 1); + allocated.put(upper.isIncluding() ? (byte) '[' : (byte) '(').put(encoded); - return createCommand(GEOPOS, new GeoCoordinatesListOutput(codec), args); + return allocated.array(); } - public Command geodist(K key, V from, V to, GeoArgs.Unit unit) { - notNullKey(key); - LettuceAssert.notNull(from, "From " + MUST_NOT_BE_NULL); - LettuceAssert.notNull(from, "To " + MUST_NOT_BE_NULL); + private byte[] minValue(Range range) { - CommandArgs args = new CommandArgs(codec).addKey(key).addValue(from).addValue(to); + Range.Boundary lower = range.getLower(); - if (unit != null) { - args.add(unit.name()); + if (lower.getValue() == null) { + return MINUS_BYTES; } - return createCommand(GEODIST, new DoubleOutput(codec), args); + ByteBuffer encoded = codec.encodeValue(lower.getValue()); + ByteBuffer allocated = ByteBuffer.allocate(encoded.remaining() + 1); + allocated.put(lower.isIncluding() ? (byte) '[' : (byte) '(').put(encoded); + + return allocated.array(); } - public static void notNull(ScoredValueStreamingChannel channel) { + static void notNull(ScoredValueStreamingChannel channel) { LettuceAssert.notNull(channel, "ScoredValueStreamingChannel " + MUST_NOT_BE_NULL); } - public static void notNull(KeyStreamingChannel channel) { + static void notNull(KeyStreamingChannel channel) { LettuceAssert.notNull(channel, "KeyValueStreamingChannel " + MUST_NOT_BE_NULL); } - public static void notNull(ValueStreamingChannel channel) { + static void notNull(ValueStreamingChannel channel) { LettuceAssert.notNull(channel, "ValueStreamingChannel " + MUST_NOT_BE_NULL); } - public static void notNull(KeyValueStreamingChannel channel) { + static void notNull(KeyValueStreamingChannel channel) { LettuceAssert.notNull(channel, "KeyValueStreamingChannel " + MUST_NOT_BE_NULL); } - private static void notNullKey(Object key) { - LettuceAssert.notNull(key, "Key " + MUST_NOT_BE_NULL); - } - - private static void notNullRange(Range range) { - LettuceAssert.notNull(range, "Range " + MUST_NOT_BE_NULL); - } - - private static void notNullLimit(Limit limit) { - LettuceAssert.notNull(limit, "Limit " + MUST_NOT_BE_NULL); - } - - public static void notNullMinMax(String min, String max) { + static void notNullMinMax(String min, String max) { LettuceAssert.notNull(min, "Min " + MUST_NOT_BE_NULL); LettuceAssert.notNull(max, "Max " + MUST_NOT_BE_NULL); } - private static void notEmpty(Object[] keys) { - LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(keys, "Keys " + MUST_NOT_BE_EMPTY); - } - - private static void notEmptyValues(Object[] values) { - LettuceAssert.notNull(values, "Values " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(values, "Values " + MUST_NOT_BE_EMPTY); - } - - private static void assertNodeId(String nodeId) { - LettuceAssert.notNull(nodeId, "NodeId " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(nodeId, "NodeId " + MUST_NOT_BE_EMPTY); - } - - private static void notEmptySlots(int[] slots) { - LettuceAssert.notNull(slots, "Slots " + MUST_NOT_BE_NULL); - LettuceAssert.notEmpty(slots, "Slots " + MUST_NOT_BE_EMPTY); - } - private static void addLimit(CommandArgs args, Limit limit) { if (limit.isLimited()) { @@ -2735,20 +2729,9 @@ private static void addLimit(CommandArgs args, Limit limit) { } } - private static String min(Range range) { - - Range.Boundary lower = range.getLower(); - - if (lower.getValue() == null || lower.getValue() instanceof Double - && lower.getValue().doubleValue() == Double.NEGATIVE_INFINITY) { - return "-inf"; - } - - if (!lower.isIncluding()) { - return "(" + lower.getValue(); - } - - return lower.getValue().toString(); + private static void assertNodeId(String nodeId) { + LettuceAssert.notNull(nodeId, "NodeId " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(nodeId, "NodeId " + MUST_NOT_BE_EMPTY); } private static String max(Range range) { @@ -2767,33 +2750,46 @@ private static String max(Range range) { return upper.getValue().toString(); } - private byte[] minValue(Range range) { + private static String min(Range range) { - Range.Boundary lower = range.getLower(); + Range.Boundary lower = range.getLower(); - if (lower.getValue() == null) { - return MINUS_BYTES; + if (lower.getValue() == null || lower.getValue() instanceof Double + && lower.getValue().doubleValue() == Double.NEGATIVE_INFINITY) { + return "-inf"; } - ByteBuffer encoded = codec.encodeValue(lower.getValue()); - ByteBuffer allocated = ByteBuffer.allocate(encoded.remaining() + 1); - allocated.put(lower.isIncluding() ? (byte) '[' : (byte) '(').put(encoded); + if (!lower.isIncluding()) { + return "(" + lower.getValue(); + } - return allocated.array(); + return lower.getValue().toString(); } - private byte[] maxValue(Range range) { + private static void notEmpty(Object[] keys) { + LettuceAssert.notNull(keys, "Keys " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(keys, "Keys " + MUST_NOT_BE_EMPTY); + } - Range.Boundary upper = range.getUpper(); + private static void notEmptySlots(int[] slots) { + LettuceAssert.notNull(slots, "Slots " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(slots, "Slots " + MUST_NOT_BE_EMPTY); + } - if (upper.getValue() == null) { - return PLUS_BYTES; - } + private static void notEmptyValues(Object[] values) { + LettuceAssert.notNull(values, "Values " + MUST_NOT_BE_NULL); + LettuceAssert.notEmpty(values, "Values " + MUST_NOT_BE_EMPTY); + } - ByteBuffer encoded = codec.encodeValue(upper.getValue()); - ByteBuffer allocated = ByteBuffer.allocate(encoded.remaining() + 1); - allocated.put(upper.isIncluding() ? (byte) '[' : (byte) '(').put(encoded); + private static void notNullKey(Object key) { + LettuceAssert.notNull(key, "Key " + MUST_NOT_BE_NULL); + } - return allocated.array(); + private static void notNullLimit(Limit limit) { + LettuceAssert.notNull(limit, "Limit " + MUST_NOT_BE_NULL); + } + + private static void notNullRange(Range range) { + LettuceAssert.notNull(range, "Range " + MUST_NOT_BE_NULL); } }