From e77020ef83f83fb07d6a9961381a2d1c6262e42b Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 17 Jun 2014 17:48:02 +0200 Subject: [PATCH 1/8] Support for PUBSUB --- README.md | 2 +- .../redis/BaseRedisAsyncConnection.java | 9 +++++ .../redis/BaseRedisConnection.java | 9 +++++ .../redis/RedisAsyncConnectionImpl.java | 20 ++++++++++ .../redis/RedisCommandBuilder.java | 20 ++++++++++ .../redis/protocol/CommandKeyword.java | 2 +- .../redis/protocol/CommandType.java | 2 +- .../lambdaworks/redis/PubSubCommandTest.java | 39 +++++++++++++++++++ 8 files changed, 100 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26784a1a9b..6f15411e0e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Lettuce works with: Currently following commands are __not yet__ supported: -* Server Commands: DEBUG SEGFAULT, MONITOR, PUBSUB +* Server Commands: MONITOR I'm pursuing the client code as a fork since the latest changes weren't merged back into https://github/wg/lettuce I'd love not adding yet another Java redis client, but unfortunately it's the current situation. diff --git a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java index a02d4daaf8..1f9705591e 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java @@ -2,6 +2,7 @@ import java.io.Closeable; import java.util.List; +import java.util.Map; /** * @@ -16,6 +17,14 @@ public interface BaseRedisAsyncConnection extends Closeable { RedisFuture publish(K channel, V message); + RedisFuture> pubsubChannels(); + + RedisFuture> pubsubChannels(K channel); + + RedisFuture> pubsubNumsub(K... channels); + + RedisFuture pubsubNumpat(); + RedisFuture echo(V msg); RedisFuture ping(); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java index d212bf1efa..0eff4c06e0 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java @@ -2,6 +2,7 @@ import java.io.Closeable; import java.util.List; +import java.util.Map; /** * @@ -16,6 +17,14 @@ public interface BaseRedisConnection extends Closeable { Long publish(K channel, V message); + List pubsubChannels(); + + List pubsubChannels(K channel); + + Map pubsubNumsub(K... channels); + + Long pubsubNumpat(); + V echo(V msg); String ping(); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java index 32b671bf77..9a736226c8 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisAsyncConnectionImpl.java @@ -592,6 +592,26 @@ public RedisFuture publish(K channel, V message) { return dispatch(commandBuilder.publish(channel, message)); } + @Override + public RedisFuture> pubsubChannels() { + return dispatch(commandBuilder.pubsubChannels()); + } + + @Override + public RedisFuture> pubsubChannels(K channel) { + return dispatch(commandBuilder.pubsubChannels(channel)); + } + + @Override + public RedisFuture> pubsubNumsub(K... channels) { + return dispatch(commandBuilder.pubsubNumsub(channels)); + } + + @Override + public RedisFuture pubsubNumpat() { + return dispatch(commandBuilder.pubsubNumpat()); + } + @Override public RedisFuture quit() { return dispatch(commandBuilder.quit()); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java index 6daecd711e..13817367a5 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java @@ -506,6 +506,26 @@ public Command publish(K channel, V 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); + } + + public Command> pubsubChannels(K pattern) { + CommandArgs args = new CommandArgs(codec).add(CHANNELS).addKey(pattern); + return createCommand(PUBSUB, new KeyListOutput(codec), args); + } + + public Command> pubsubNumsub(K... 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); + } + public Command quit() { return createCommand(QUIT, new StatusOutput(codec)); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandKeyword.java b/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandKeyword.java index b56bbdb3ce..4e2e9aa9ad 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandKeyword.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandKeyword.java @@ -8,7 +8,7 @@ * @author Will Glozer */ public enum CommandKeyword { - ADDSLOTS, AFTER, AGGREGATE, ALPHA, AND, ASC, BEFORE, BY, COUNT, DELSLOTS, DESC, SOFT, HARD, ENCODING, FAILOVER, FORGET, FLUSH, FORCE, FLUSHSLOTS, GETNAME, GETKEYSINSLOT, IDLETIME, KILL, LEN, LIMIT, LIST, LOAD, MATCH, MAX, MEET, MIN, MOVED, NO, NODE, NODES, NOSAVE, NOT, ONE, OR, PAUSE, REFCOUNT, REPLICATE, RESET, REWRITE, RESETSTAT, SETNAME, SETSLOT, MIGRATING, IMPORTING, SLAVES, STORE, SUM, SEGFAULT, WEIGHTS, WITHSCORES, XOR, REMOVE; + ADDSLOTS, AFTER, AGGREGATE, ALPHA, AND, ASC, BEFORE, BY, CHANNELS, COUNT, DELSLOTS, DESC, SOFT, HARD, ENCODING, FAILOVER, FORGET, FLUSH, FORCE, FLUSHSLOTS, GETNAME, GETKEYSINSLOT, IDLETIME, KILL, LEN, LIMIT, LIST, LOAD, MATCH, MAX, MEET, MIN, MOVED, NO, NODE, NODES, NOSAVE, NOT, NUMSUB, NUMPAT, ONE, OR, PAUSE, REFCOUNT, REPLICATE, RESET, REWRITE, RESETSTAT, SETNAME, SETSLOT, MIGRATING, IMPORTING, SLAVES, STORE, SUM, SEGFAULT, WEIGHTS, WITHSCORES, XOR, REMOVE; public byte[] bytes; diff --git a/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandType.java b/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandType.java index 88403298f5..c2f194558b 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandType.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/protocol/CommandType.java @@ -46,7 +46,7 @@ public enum CommandType { // Pub/Sub - PSUBSCRIBE, PUBLISH, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE, + PSUBSCRIBE, PUBLISH, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE, PUBSUB, // Sets diff --git a/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java b/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java index 6d02ea8193..c0b7e7d248 100644 --- a/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java +++ b/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java @@ -2,9 +2,13 @@ package com.lambdaworks.redis; +import static org.hamcrest.CoreMatchers.hasItem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import java.util.List; +import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; @@ -92,6 +96,41 @@ public void psubscribe() throws Exception { assertEquals(1, (long) counts.take()); } + @Test + public void pubsubChannels() throws Exception { + pubsub.subscribe(channel); + + List result = redis.pubsubChannels(); + assertThat(result, hasItem(channel)); + } + + @Test + public void pubsubChannelsWithArg() throws Exception { + pubsub.subscribe(channel); + + List result = redis.pubsubChannels(pattern); + assertThat(result, hasItem(channel)); + } + + @Test + public void pubsubNumsub() throws Exception { + + pubsub.subscribe(channel); + + Map result = redis.pubsubNumsub(channel); + assertEquals(1, result.size()); + assertEquals("1", result.get(channel)); + } + + @Test + public void pubsubNumpat() throws Exception { + + pubsub.psubscribe(pattern); + + Long result = redis.pubsubNumpat(); + assertEquals(1L, result.longValue()); + } + @Test(timeout = 200) public void punsubscribe() throws Exception { pubsub.punsubscribe(pattern); From f05e960d058aff22ddd36f88758f32ee9e54e574 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 08:02:20 +0200 Subject: [PATCH 2/8] Fixed PubSub API --- .../redis/pubsub/RedisPubSubConnection.java | 15 +++++++++++++++ .../com/lambdaworks/redis/PubSubCommandTest.java | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lettuce/src/main/java/com/lambdaworks/redis/pubsub/RedisPubSubConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/pubsub/RedisPubSubConnection.java index 1a264c8b01..8b0441869a 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/pubsub/RedisPubSubConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/pubsub/RedisPubSubConnection.java @@ -9,6 +9,21 @@ * @since 26.05.14 08:39 */ public interface RedisPubSubConnection extends RedisAsyncConnection { + + /** + * Add a new listener. + * + * @param listener Listener. + */ + void addListener(RedisPubSubListener listener); + + /** + * Remove an existing listener. + * + * @param listener Listener. + */ + void removeListener(RedisPubSubListener listener); + void psubscribe(K... patterns); void punsubscribe(K... patterns); diff --git a/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java b/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java index c0b7e7d248..113b781cf8 100644 --- a/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java +++ b/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java @@ -13,6 +13,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import com.lambdaworks.redis.pubsub.RedisPubSubConnection; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -22,7 +23,7 @@ import com.lambdaworks.redis.pubsub.RedisPubSubListener; public class PubSubCommandTest extends AbstractCommandTest implements RedisPubSubListener { - private RedisPubSubConnectionImpl pubsub; + private RedisPubSubConnection pubsub; private BlockingQueue channels; private BlockingQueue patterns; From 202d681ae3371e78b1442bf20720356b618160fe Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 08:02:29 +0200 Subject: [PATCH 3/8] git ignores --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 783e0effc7..0a3dd90a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ atlassian-ide-plugin.xml redis-git *.releaseBackup release.properties +work/ From 15daf1dc611f392aa429d44e79230e0f0e5bb13d Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 13:42:05 +0200 Subject: [PATCH 4/8] Documentation --- .../redis/BaseRedisAsyncConnection.java | 13 ++++++++++--- .../lambdaworks/redis/BaseRedisConnection.java | 13 ++++++++++--- .../com/lambdaworks/redis/Connections.java | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java index 1f9705591e..34b2a11b45 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java @@ -31,9 +31,6 @@ public interface BaseRedisAsyncConnection extends Closeable { RedisFuture quit(); - @Override - void close(); - String digest(V script); RedisFuture discard(); @@ -48,6 +45,16 @@ public interface BaseRedisAsyncConnection extends Closeable { RedisFuture waitForReplication(int replicas, long timeout); + /** + * Close the connection. The connection will become not usable anymore as soon as this method was called. + */ + @Override + void close(); + + /** + * + * @return true if the connection is open (connected and not closed). + */ boolean isOpen(); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java index 0eff4c06e0..fec6d5391c 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java @@ -31,9 +31,6 @@ public interface BaseRedisConnection extends Closeable { String quit(); - @Override - void close(); - String digest(V script); String discard(); @@ -48,6 +45,16 @@ public interface BaseRedisConnection extends Closeable { Long waitForReplication(int replicas, long timeout); + /** + * Close the connection. The connection will become not usable anymore as soon as this method was called. + */ + @Override + void close(); + + /** + * + * @return true if the connection is open (connected and not closed). + */ boolean isOpen(); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/Connections.java b/lettuce/src/main/java/com/lambdaworks/redis/Connections.java index 9c418bab01..41e4ebf17c 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/Connections.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/Connections.java @@ -5,10 +5,18 @@ import java.util.concurrent.ExecutionException; /** + * Utility for checking a connection's state. + * * @author Mark Paluch * @since 14.05.14 22:05 */ public class Connections { + + /** + * + * @param connection + * @return true if the connection is valid (ping works). + */ public final static boolean isValid(Object connection) { checkNotNull(connection, "connection must not be null"); @@ -39,6 +47,11 @@ public final static boolean isValid(Object connection) { throw new IllegalArgumentException("Connection class " + connection.getClass() + " not supported"); } + /** + * + * @param connection + * @return true if the connection is open. + */ public final static boolean isOpen(Object connection) { checkNotNull(connection, "connection must not be null"); @@ -55,6 +68,11 @@ public final static boolean isOpen(Object connection) { throw new IllegalArgumentException("Connection class " + connection.getClass() + " not supported"); } + /** + * Closes a connection. + * + * @param connection + */ public static void close(Object connection) { checkNotNull(connection, "connection must not be null"); From 1a12055ccfc078e0855b1c5b739133474e8eabd4 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 14:07:36 +0200 Subject: [PATCH 5/8] Documentation --- .../redis/BaseRedisAsyncConnection.java | 74 +++++ .../redis/BaseRedisConnection.java | 73 +++++ .../redis/RedisHLLAsyncConnection.java | 19 ++ .../lambdaworks/redis/RedisHLLConnection.java | 19 ++ .../redis/RedisHashesAsyncConnection.java | 152 +++++++++ .../redis/RedisHashesConnection.java | 151 +++++++++ .../redis/RedisKeysAsyncConnection.java | 218 ++++++++++++ .../redis/RedisKeysConnection.java | 217 ++++++++++++ .../redis/RedisListsAsyncConnection.java | 141 +++++++- .../redis/RedisListsConnection.java | 138 ++++++++ .../redis/RedisScriptingAsyncConnection.java | 22 ++ .../redis/RedisScriptingConnection.java | 22 ++ .../redis/RedisSentinelAsyncConnection.java | 44 +++ .../redis/RedisServerAsyncConnection.java | 68 ++++ .../redis/RedisServerConnection.java | 68 ++++ .../redis/RedisSetsAsyncConnection.java | 162 +++++++++ .../redis/RedisSetsConnection.java | 161 +++++++++ .../redis/RedisSortedSetsAsyncConnection.java | 310 +++++++++++++++++- .../redis/RedisSortedSetsConnection.java | 303 ++++++++++++++++- .../redis/RedisStringsAsyncConnection.java | 202 ++++++++++++ .../redis/RedisStringsConnection.java | 201 ++++++++++++ 21 files changed, 2757 insertions(+), 8 deletions(-) diff --git a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java index 34b2a11b45..53034bf644 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisAsyncConnection.java @@ -15,32 +15,106 @@ */ public interface BaseRedisAsyncConnection extends Closeable { + /** + * Post a message to a channel. + * + * @param channel the channel type: key + * @param message the message type: value + * @return RedisFuture integer-reply the number of clients that received the message. + */ RedisFuture publish(K channel, V message); + /** + * Lists the currently *active channels*. + * + * @return RedisFuture> array-reply a list of active channels, optionally matching the specified pattern. + */ RedisFuture> pubsubChannels(); + /** + * Lists the currently *active channels*. + * + * @param channel the key + * @return RedisFuture> array-reply a list of active channels, optionally matching the specified pattern. + */ RedisFuture> pubsubChannels(K channel); + /** + * Returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels. + * + * @param channels + * @return array-reply a list of channels and number of subscribers for every channel. + */ RedisFuture> pubsubNumsub(K... channels); + /** + * Returns the number of subscriptions to patterns. + * + * @return RedisFuture integer-reply the number of patterns all the clients are subscribed to. + */ RedisFuture pubsubNumpat(); + /** + * Echo the given string. + * + * @param msg the message type: value + * @return RedisFuture bulk-string-reply + */ RedisFuture echo(V msg); + /** + * Ping the server. + * + * @return RedisFuture simple-string-reply + */ RedisFuture ping(); + /** + * Close the connection. + * + * @return RedisFuture simple-string-reply always OK. + */ RedisFuture quit(); String digest(V script); + /** + * Discard all commands issued after MULTI. + * + * @return RedisFuture simple-string-reply always `OK`. + */ RedisFuture discard(); + /** + * Execute all commands issued after MULTI. + * + * @return RedisFuture> array-reply each element being the reply to each of the commands in the atomic + * transaction. + * + * When using `WATCH`, `EXEC` can return a + */ RedisFuture> exec(); + /** + * Mark the start of a transaction block. + * + * @return RedisFuture simple-string-reply always `OK`. + */ RedisFuture multi(); + /** + * Watch the given keys to determine execution of the MULTI/EXEC block. + * + * @param keys the key + * @return RedisFuture simple-string-reply always `OK`. + */ RedisFuture watch(K... keys); + /** + * Forget about all watched keys. + * + * @return RedisFuture simple-string-reply always `OK`. + */ RedisFuture unwatch(); RedisFuture waitForReplication(int replicas, long timeout); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java index fec6d5391c..eaa6d2ae50 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/BaseRedisConnection.java @@ -15,32 +15,105 @@ */ public interface BaseRedisConnection extends Closeable { + /** + * Post a message to a channel. + * + * @param channel the channel type: key + * @param message the message type: value + * @return Long integer-reply the number of clients that received the message. + */ Long publish(K channel, V message); + /** + * Lists the currently *active channels*. + * + * @return List array-reply a list of active channels, optionally matching the specified pattern. + */ List pubsubChannels(); + /** + * Lists the currently *active channels*. + * + * @param channel the key + * @return List array-reply a list of active channels, optionally matching the specified pattern. + */ List pubsubChannels(K channel); + /** + * Returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels. + * + * @param channels + * @return array-reply a list of channels and number of subscribers for every channel. + */ Map pubsubNumsub(K... channels); + /** + * Returns the number of subscriptions to patterns. + * + * @return Long integer-reply the number of patterns all the clients are subscribed to. + */ Long pubsubNumpat(); + /** + * Echo the given string. + * + * @param msg the message type: value + * @return V bulk-string-reply + */ V echo(V msg); + /** + * Ping the server. + * + * @return String simple-string-reply + */ String ping(); + /** + * Close the connection. + * + * @return String simple-string-reply always OK. + */ String quit(); String digest(V script); + /** + * Discard all commands issued after MULTI. + * + * @return String simple-string-reply always `OK`. + */ String discard(); + /** + * Execute all commands issued after MULTI. + * + * @return List array-reply each element being the reply to each of the commands in the atomic transaction. + * + * When using `WATCH`, `EXEC` can return a + */ List exec(); + /** + * Mark the start of a transaction block. + * + * @return String simple-string-reply always `OK`. + */ String multi(); + /** + * Watch the given keys to determine execution of the MULTI/EXEC block. + * + * @param keys the key + * @return String simple-string-reply always `OK`. + */ String watch(K... keys); + /** + * Forget about all watched keys. + * + * @return String simple-string-reply always `OK`. + */ String unwatch(); Long waitForReplication(int replicas, long timeout); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLAsyncConnection.java index 05086b2615..af1a22dbdc 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLAsyncConnection.java @@ -9,10 +9,29 @@ * @since 17.05.14 21:14 */ public interface RedisHLLAsyncConnection { + /** + * Adds the specified elements to the specified HyperLogLog. + * + * @return RedisFuture integer-reply specifically: + * + * 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise. + */ RedisFuture pfadd(K key, V value, V... moreValues); + /** + * Merge N different HyperLogLogs into a single one. + * + * @return RedisFuture simple-string-reply The command just returns `OK`. + */ RedisFuture pfmerge(K destkey, K sourcekey, K... moreSourceKeys); + /** + * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). + * + * @return RedisFuture integer-reply specifically: + * + * The approximated number of unique elements observed via `PFADD`. + */ RedisFuture pfcount(K key, K... moreKeys); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLConnection.java index bf0c742848..167924de0e 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisHLLConnection.java @@ -9,10 +9,29 @@ * @since 17.05.14 21:14 */ public interface RedisHLLConnection { + /** + * Adds the specified elements to the specified HyperLogLog. + * + * @return Long integer-reply specifically: + * + * 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise. + */ Long pfadd(K key, V value, V... moreValues); + /** + * Merge N different HyperLogLogs into a single one. + * + * @return Long simple-string-reply The command just returns `OK`. + */ Long pfmerge(K destkey, K sourcekey, K... moreSourceKeys); + /** + * Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). + * + * @return Long integer-reply specifically: + * + * The approximated number of unique elements observed via `PFADD`. + */ Long pfcount(K key, K... moreKeys); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java index 8404573604..14e989a091 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java @@ -17,53 +17,205 @@ */ public interface RedisHashesAsyncConnection { + /** + * Delete one or more hash fields. + * + * @param key the key + * @param fields the field type: key + * @return RedisFuture integer-reply the number of fields that were removed from the hash, not including specified but + * non existing fields. + */ RedisFuture hdel(K key, K... fields); + /** + * Determine if a hash field exists. + * + * @param key the key + * @param field the field type: key + * @return RedisFuture integer-reply specifically: + * + * `1` if the hash contains `field`. `0` if the hash does not contain `field`, or `key` does not exist. + */ RedisFuture hexists(K key, K field); + /** + * Get the value of a hash field. + * + * @param key the key + * @param field the field type: key + * @return RedisFuture bulk-string-reply the value associated with `field`, or `nil` when `field` is not present in the + * hash or `key` does not exist. + */ RedisFuture hget(K key, K field); + /** + * Increment the integer value of a hash field by the given number. + * + * @param key the key + * @param field the field type: key + * @param amount the increment type: long + * @return RedisFuture integer-reply the value at `field` after the increment operation. + */ RedisFuture hincrby(K key, K field, long amount); + /** + * Increment the float value of a hash field by the given amount. + * + * @param key the key + * @param field the field type: key + * @param amount the increment type: double + * @return RedisFuture bulk-string-reply the value of `field` after the increment. + */ RedisFuture hincrbyfloat(K key, K field, double amount); + /** + * Get all the fields and values in a hash. + * + * @param key the key + * @return RedisFuture> array-reply list of fields and their values stored in the hash, or an empty list when `key` + * does not exist. + */ RedisFuture> hgetall(K key); + /** + * Get all the fields and values in a hash. + * + * @return RedisFuture array-reply list of fields and their values stored in the hash, or an empty list when `key` + * does not exist. + */ RedisFuture hgetall(KeyValueStreamingChannel channel, K key); + /** + * Get all the fields in a hash. + * + * @param key the key + * @return RedisFuture> array-reply list of fields in the hash, or an empty list when `key` does not exist. + */ RedisFuture> hkeys(K key); + /** + * Get all the fields in a hash. + * + * @return RedisFuture array-reply list of fields in the hash, or an empty list when `key` does not exist. + */ RedisFuture hkeys(KeyStreamingChannel channel, K key); + /** + * Get the number of fields in a hash. + * + * @param key the key + * @return RedisFuture integer-reply number of fields in the hash, or `0` when `key` does not exist. + */ RedisFuture hlen(K key); + /** + * Get the values of all the given hash fields. + * + * @param key the key + * @param fields the field type: key + * @return RedisFuture> array-reply list of values associated with the given fields, in the same + */ RedisFuture> hmget(K key, K... fields); + /** + * Get the values of all the given hash fields. + * + * @return RedisFuture array-reply list of values associated with the given fields, in the same + */ RedisFuture hmget(ValueStreamingChannel channel, K key, K... fields); + /** + * Set multiple hash fields to multiple values. + * + * @param key the key + * @param map the null + * @return RedisFuture simple-string-reply + */ RedisFuture hmset(K key, Map map); + /** + * Set the string value of a hash field. + * + * @param key the key + * @param field the field type: key + * @param value the value type: value + * @return RedisFuture integer-reply specifically: + * + * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and the + * value was updated. + */ RedisFuture hset(K key, K field, V value); + /** + * Set the value of a hash field, only if the field does not exist. + * + * @param key the key + * @param field the field type: key + * @param value the value type: value + * @return RedisFuture integer-reply specifically: + * + * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and no + * operation was performed. + */ RedisFuture hsetnx(K key, K field, V value); + /** + * Get all the values in a hash. + * + * @param key the key + * @return RedisFuture> array-reply list of values in the hash, or an empty list when `key` does not exist. + */ RedisFuture> hvals(K key); + /** + * Get all the values in a hash. + * + * @return RedisFuture array-reply list of values in the hash, or an empty list when `key` does not exist. + */ RedisFuture hvals(ValueStreamingChannel channel, K key); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture> hscan(K key); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture> hscan(K key, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture> hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture> hscan(K key, ScanCursor scanCursor); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture hscan(KeyValueStreamingChannel channel, K key); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + * + * @param channel the key + * @param key the cursor type: long + * @param scanCursor the pattern type: pattern + * @param scanArgs the count type: long + */ RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + */ RedisFuture hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java index 03d6ce212b..8c2c9a7975 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java @@ -17,53 +17,204 @@ */ public interface RedisHashesConnection { + /** + * Delete one or more hash fields. + * + * @param key the key + * @param fields the field type: key + * @return Long integer-reply the number of fields that were removed from the hash, not including specified but non existing + * fields. + */ Long hdel(K key, K... fields); + /** + * Determine if a hash field exists. + * + * @param key the key + * @param field the field type: key + * @return Boolean integer-reply specifically: + * + * `1` if the hash contains `field`. `0` if the hash does not contain `field`, or `key` does not exist. + */ Boolean hexists(K key, K field); + /** + * Get the value of a hash field. + * + * @param key the key + * @param field the field type: key + * @return V bulk-string-reply the value associated with `field`, or `nil` when `field` is not present in the hash or `key` + * does not exist. + */ V hget(K key, K field); + /** + * Increment the integer value of a hash field by the given number. + * + * @param key the key + * @param field the field type: key + * @param amount the increment type: long + * @return Long integer-reply the value at `field` after the increment operation. + */ Long hincrby(K key, K field, long amount); + /** + * Increment the float value of a hash field by the given amount. + * + * @param key the key + * @param field the field type: key + * @param amount the increment type: double + * @return Double bulk-string-reply the value of `field` after the increment. + */ Double hincrbyfloat(K key, K field, double amount); + /** + * Get all the fields and values in a hash. + * + * @param key the key + * @return Map array-reply list of fields and their values stored in the hash, or an empty list when `key` does not + * exist. + */ Map hgetall(K key); + /** + * Get all the fields and values in a hash. + * + * @return Long array-reply list of fields and their values stored in the hash, or an empty list when `key` does not exist. + */ Long hgetall(KeyValueStreamingChannel channel, K key); + /** + * Get all the fields in a hash. + * + * @param key the key + * @return List array-reply list of fields in the hash, or an empty list when `key` does not exist. + */ List hkeys(K key); + /** + * Get all the fields in a hash. + * + * @return Long array-reply list of fields in the hash, or an empty list when `key` does not exist. + */ Long hkeys(KeyStreamingChannel channel, K key); + /** + * Get the number of fields in a hash. + * + * @param key the key + * @return Long integer-reply number of fields in the hash, or `0` when `key` does not exist. + */ Long hlen(K key); + /** + * Get the values of all the given hash fields. + * + * @param key the key + * @param fields the field type: key + * @return List array-reply list of values associated with the given fields, in the same + */ List hmget(K key, K... fields); + /** + * Get the values of all the given hash fields. + * + * @return Long array-reply list of values associated with the given fields, in the same + */ Long hmget(ValueStreamingChannel channel, K key, K... fields); + /** + * Set multiple hash fields to multiple values. + * + * @param key the key + * @param map the null + * @return String simple-string-reply + */ String hmset(K key, Map map); + /** + * Set the string value of a hash field. + * + * @param key the key + * @param field the field type: key + * @param value the value type: value + * @return Boolean integer-reply specifically: + * + * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and the + * value was updated. + */ Boolean hset(K key, K field, V value); + /** + * Set the value of a hash field, only if the field does not exist. + * + * @param key the key + * @param field the field type: key + * @param value the value type: value + * @return Boolean integer-reply specifically: + * + * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and no + * operation was performed. + */ Boolean hsetnx(K key, K field, V value); + /** + * Get all the values in a hash. + * + * @param key the key + * @return List array-reply list of values in the hash, or an empty list when `key` does not exist. + */ List hvals(K key); + /** + * Get all the values in a hash. + * + * @return Long array-reply list of values in the hash, or an empty list when `key` does not exist. + */ Long hvals(ValueStreamingChannel channel, K key); + /** + * Incrementally iterate hash fields and associated values. + */ MapScanCursor hscan(K key); + /** + * Incrementally iterate hash fields and associated values. + */ MapScanCursor hscan(K key, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + */ MapScanCursor hscan(K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + */ MapScanCursor hscan(K key, ScanCursor scanCursor); + /** + * Incrementally iterate hash fields and associated values. + */ StreamScanCursor hscan(KeyValueStreamingChannel channel, K key); + /** + * Incrementally iterate hash fields and associated values. + */ StreamScanCursor hscan(KeyValueStreamingChannel channel, K key, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + * + * @param channel + * @param key the key + * @param scanCursor the cursor type: long + * @param scanArgs + */ StreamScanCursor hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate hash fields and associated values. + */ StreamScanCursor hscan(KeyValueStreamingChannel channel, K key, ScanCursor scanCursor); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysAsyncConnection.java index edd3c0830f..9c650bc3b2 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysAsyncConnection.java @@ -15,78 +15,296 @@ * @since 17.05.14 21:10 */ public interface RedisKeysAsyncConnection { + /** + * Delete a key. + * + * @param keys the key + * @return RedisFuture integer-reply The number of keys that were removed. + */ RedisFuture del(K... keys); + /** + * Return a serialized version of the value stored at the specified key. + * + * @param key the key + * @return RedisFuture bulk-string-reply the serialized value. + */ RedisFuture dump(K key); + /** + * Determine if a key exists. + * + * @param key the key + * @return RedisFuture integer-reply specifically: + * + * `1` if the key exists. `0` if the key does not exist. + */ RedisFuture exists(K key); + /** + * Set a key's time to live in seconds. + * + * @param key the key + * @param seconds the seconds type: long + * @return RedisFuture integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set. + */ RedisFuture expire(K key, long seconds); + /** + * Set the expiration for a key as a UNIX timestamp. + * + * @param key the key + * @param timestamp the timestamp type: posix time + * @return RedisFuture integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ RedisFuture expireat(K key, Date timestamp); + /** + * Set the expiration for a key as a UNIX timestamp. + * + * @param key the key + * @param timestamp the timestamp type: posix time + * @return RedisFuture integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ RedisFuture expireat(K key, long timestamp); + /** + * Find all keys matching the given pattern. + * + * @param pattern the pattern type: patternkey (pattern) + * @return RedisFuture> array-reply list of keys matching `pattern`. + */ RedisFuture> keys(K pattern); + /** + * Find all keys matching the given pattern. + * + * @return RedisFuture array-reply list of keys matching `pattern`. + */ RedisFuture keys(KeyStreamingChannel channel, K pattern); + /** + * Atomically transfer a key from a Redis instance to another one. + * + * @return RedisFuture simple-string-reply The command returns OK on success. + */ RedisFuture migrate(String host, int port, K key, int db, long timeout); + /** + * Move a key to another database. + * + * @param key the key + * @param db the db type: long + * @return RedisFuture integer-reply specifically: + */ RedisFuture move(K key, int db); + /** + * returns the kind of internal representation used in order to store the value associated with a key. + * + * @param key the key + * @return RedisFuture + */ RedisFuture objectEncoding(K key); + /** + * returns the number of seconds since the object stored at the specified key is idle (not requested by read or write + * operations). + * + * @param key + * @return + */ RedisFuture objectIdletime(K key); + /** + * returns the number of references of the value associated with the specified key. + * + * @param key + * @return + */ RedisFuture objectRefcount(K key); + /** + * Remove the expiration from a key. + * + * @param key the key + * @return RedisFuture integer-reply specifically: + * + * `1` if the timeout was removed. `0` if `key` does not exist or does not have an associated timeout. + */ RedisFuture persist(K key); + /** + * Set a key's time to live in milliseconds. + * + * @param key the key + * @param milliseconds the milliseconds type: long + */ RedisFuture pexpire(K key, long milliseconds); + /** + * Set the expiration for a key as a UNIX timestamp specified in milliseconds. + * + * @param key the key + * @param timestamp the milliseconds-timestamp type: posix time + * @return RedisFuture integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ RedisFuture pexpireat(K key, Date timestamp); + /** + * Set the expiration for a key as a UNIX timestamp specified in milliseconds. + * + * @param key the key + * @param timestamp the milliseconds-timestamp type: posix time + * @return RedisFuture integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ RedisFuture pexpireat(K key, long timestamp); + /** + * Get the time to live for a key in milliseconds. + * + * @param key the key + * @return RedisFuture integer-reply TTL in milliseconds, or a negative value in order to signal an error (see the + * description above). + */ RedisFuture pttl(K key); + /** + * Return a random key from the keyspace. + * + * @return RedisFuture bulk-string-reply the random key, or `nil` when the database is empty. + */ RedisFuture randomkey(); + /** + * Rename a key. + * + * @param key the key + * @param newKey the newkey type: key + * @return RedisFuture simple-string-reply + */ RedisFuture rename(K key, K newKey); + /** + * Rename a key, only if the new key does not exist. + * + * @param key the key + * @param newKey the newkey type: key + * @return RedisFuture integer-reply specifically: + * + * `1` if `key` was renamed to `newkey`. `0` if `newkey` already exists. + */ RedisFuture renamenx(K key, K newKey); + /** + * Create a key using the provided serialized value, previously obtained using DUMP. + * + * @param key the key + * @param ttl the ttl type: long + * @param value the serialized-value type: string + * @return RedisFuture simple-string-reply The command returns OK on success. + */ RedisFuture restore(K key, long ttl, byte[] value); + /** + * Sort the elements in a list, set or sorted set. + * + * @return RedisFuture> array-reply list of sorted elements. + */ RedisFuture> sort(K key); + /** + * Sort the elements in a list, set or sorted set. + * + * @return RedisFuture array-reply list of sorted elements. + */ RedisFuture sort(ValueStreamingChannel channel, K key); + /** + * Sort the elements in a list, set or sorted set. + * + * @return RedisFuture> array-reply list of sorted elements. + */ RedisFuture> sort(K key, SortArgs sortArgs); + /** + * Sort the elements in a list, set or sorted set. + * + * @return RedisFuture array-reply list of sorted elements. + */ RedisFuture sort(ValueStreamingChannel channel, K key, SortArgs sortArgs); RedisFuture sortStore(K key, SortArgs sortArgs, K destination); + /** + * Get the time to live for a key. + * + * @param key the key + * @return RedisFuture integer-reply TTL in seconds, or a negative value in order to signal an error (see the + * description above). + */ RedisFuture ttl(K key); + /** + * Determine the type stored at key. + * + * @param key the key + * @return RedisFuture simple-string-reply type of `key`, or `none` when `key` does not exist. + */ RedisFuture type(K key); + /** + * Incrementally iterate the keys space. + */ RedisFuture> scan(); + /** + * Incrementally iterate the keys space. + */ RedisFuture> scan(ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + */ RedisFuture> scan(ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + */ RedisFuture> scan(ScanCursor scanCursor); + /** + * Incrementally iterate the keys space. + */ RedisFuture scan(KeyStreamingChannel channel); + /** + * Incrementally iterate the keys space. + */ RedisFuture scan(KeyStreamingChannel channel, ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + * + * @param channel + * @param scanCursor the cursor type: long + * @param scanArgs + */ RedisFuture scan(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + */ RedisFuture scan(KeyStreamingChannel channel, ScanCursor scanCursor); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysConnection.java index a1bbcc2754..9bf0ca7542 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisKeysConnection.java @@ -15,77 +15,294 @@ * @since 17.05.14 21:10 */ public interface RedisKeysConnection { + /** + * Delete a key. + * + * @param keys the key + * @return Long integer-reply The number of keys that were removed. + */ Long del(K... keys); + /** + * Return a serialized version of the value stored at the specified key. + * + * @param key the key + * @return byte[] bulk-string-reply the serialized value. + */ byte[] dump(K key); + /** + * Determine if a key exists. + * + * @param key the key + * @return Boolean integer-reply specifically: + * + * `1` if the key exists. `0` if the key does not exist. + */ Boolean exists(K key); + /** + * Set a key's time to live in seconds. + * + * @param key the key + * @param seconds the seconds type: long + * @return Boolean integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set. + */ Boolean expire(K key, long seconds); + /** + * Set the expiration for a key as a UNIX timestamp. + * + * @param key the key + * @param timestamp the timestamp type: posix time + * @return Boolean integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ Boolean expireat(K key, Date timestamp); + /** + * Set the expiration for a key as a UNIX timestamp. + * + * @param key the key + * @param timestamp the timestamp type: posix time + * @return Boolean integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ Boolean expireat(K key, long timestamp); + /** + * Find all keys matching the given pattern. + * + * @param pattern the pattern type: patternkey (pattern) + * @return List array-reply list of keys matching `pattern`. + */ List keys(K pattern); + /** + * Find all keys matching the given pattern. + * + * @return Long array-reply list of keys matching `pattern`. + */ Long keys(KeyStreamingChannel channel, K pattern); + /** + * Atomically transfer a key from a Redis instance to another one. + * + * @return String simple-string-reply The command returns OK on success. + */ String migrate(String host, int port, K key, int db, long timeout); + /** + * Move a key to another database. + * + * @param key the key + * @param db the db type: long + * @return Boolean integer-reply specifically: + */ Boolean move(K key, int db); + /** + * returns the kind of internal representation used in order to store the value associated with a key. + * + * @param key + * @return + */ String objectEncoding(K key); + /** + * returns the number of seconds since the object stored at the specified key is idle (not requested by read or write + * operations). + * + * @param key + * @return + */ Long objectIdletime(K key); + /** + * returns the number of references of the value associated with the specified key. + * + * @param key + * @return + */ Long objectRefcount(K key); + /** + * Remove the expiration from a key. + * + * @param key the key + * @return Boolean integer-reply specifically: + * + * `1` if the timeout was removed. `0` if `key` does not exist or does not have an associated timeout. + */ Boolean persist(K key); + /** + * Set a key's time to live in milliseconds. + * + * @param key the key + * @param milliseconds the milliseconds type: long + */ Boolean pexpire(K key, long milliseconds); + /** + * Set the expiration for a key as a UNIX timestamp specified in milliseconds. + * + * @param key the key + * @param timestamp the milliseconds-timestamp type: posix time + * @return Boolean integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ Boolean pexpireat(K key, Date timestamp); + /** + * Set the expiration for a key as a UNIX timestamp specified in milliseconds. + * + * @param key the key + * @param timestamp the milliseconds-timestamp type: posix time + * @return Boolean integer-reply specifically: + * + * `1` if the timeout was set. `0` if `key` does not exist or the timeout could not be set (see: `EXPIRE`). + */ Boolean pexpireat(K key, long timestamp); + /** + * Get the time to live for a key in milliseconds. + * + * @param key the key + * @return Long integer-reply TTL in milliseconds, or a negative value in order to signal an error (see the description + * above). + */ Long pttl(K key); + /** + * Return a random key from the keyspace. + * + * @return V bulk-string-reply the random key, or `nil` when the database is empty. + */ V randomkey(); + /** + * Rename a key. + * + * @param key the key + * @param newKey the newkey type: key + * @return String simple-string-reply + */ String rename(K key, K newKey); + /** + * Rename a key, only if the new key does not exist. + * + * @param key the key + * @param newKey the newkey type: key + * @return Boolean integer-reply specifically: + * + * `1` if `key` was renamed to `newkey`. `0` if `newkey` already exists. + */ Boolean renamenx(K key, K newKey); + /** + * Create a key using the provided serialized value, previously obtained using DUMP. + * + * @param key the key + * @param ttl the ttl type: long + * @param value the serialized-value type: string + * @return String simple-string-reply The command returns OK on success. + */ String restore(K key, long ttl, byte[] value); + /** + * Sort the elements in a list, set or sorted set. + * + * @return List array-reply list of sorted elements. + */ List sort(K key); + /** + * Sort the elements in a list, set or sorted set. + * + * @return Long array-reply list of sorted elements. + */ Long sort(ValueStreamingChannel channel, K key); + /** + * Sort the elements in a list, set or sorted set. + * + * @return List array-reply list of sorted elements. + */ List sort(K key, SortArgs sortArgs); + /** + * Sort the elements in a list, set or sorted set. + * + * @return Long array-reply list of sorted elements. + */ Long sort(ValueStreamingChannel channel, K key, SortArgs sortArgs); Long sortStore(K key, SortArgs sortArgs, K destination); + /** + * Get the time to live for a key. + * + * @param key the key + * @return Long integer-reply TTL in seconds, or a negative value in order to signal an error (see the description above). + */ Long ttl(K key); + /** + * Determine the type stored at key. + * + * @param key the key + * @return String simple-string-reply type of `key`, or `none` when `key` does not exist. + */ String type(K key); + /** + * Incrementally iterate the keys space. + */ KeyScanCursor scan(); + /** + * Incrementally iterate the keys space. + */ KeyScanCursor scan(ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + */ KeyScanCursor scan(ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + */ KeyScanCursor scan(ScanCursor scanCursor); + /** + * Incrementally iterate the keys space. + */ StreamScanCursor scan(KeyStreamingChannel channel); + /** + * Incrementally iterate the keys space. + */ StreamScanCursor scan(KeyStreamingChannel channel, ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + * + * @param channel + * @param scanCursor the cursor type: long + * @param scanArgs + */ StreamScanCursor scan(KeyStreamingChannel channel, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate the keys space. + */ StreamScanCursor scan(KeyStreamingChannel channel, ScanCursor scanCursor); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java index b6fc8a1056..b5e677b869 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java @@ -13,39 +13,176 @@ * @since 17.05.14 21:14 */ public interface RedisListsAsyncConnection { + /** + * Remove and get the first element in a list, or block until one is available. + * + * @param timeout the key + * @param keys the timeout type: long + * @return RedisFuture> array-reply specifically: + * + * A `nil` multi-bulk when no element could be popped and the timeout expired. A two-element multi-bulk with the + * first element being the name of the key where an element was popped and the second element being the value of the + * popped element. + */ RedisFuture> blpop(long timeout, K... keys); + /** + * Remove and get the last element in a list, or block until one is available. + * + * @param timeout the key + * @param keys the timeout type: long + * @return RedisFuture> array-reply specifically: + * + * A `nil` multi-bulk when no element could be popped and the timeout expired. A two-element multi-bulk with the + * first element being the name of the key where an element was popped and the second element being the value of the + * popped element. + */ RedisFuture> brpop(long timeout, K... keys); + /** + * Pop a value from a list, push it to another list and return it; or block until one is available. + * + * @param timeout the source type: key + * @param source the destination type: key + * @param destination the timeout type: long + * @return RedisFuture bulk-string-reply the element being popped from `source` and pushed to `destination`. If `timeout` + * is reached, a + */ RedisFuture brpoplpush(long timeout, K source, K destination); + /** + * Get an element from a list by its index. + * + * @param key the key + * @param index the index type: long + * @return RedisFuture bulk-string-reply the requested element, or `nil` when `index` is out of range. + */ RedisFuture lindex(K key, long index); + /** + * Insert an element before or after another element in a list. + * + * @param key the key + * @param before the where type: enum + * @param pivot the pivot type: value + * @param value the value type: value + * @return RedisFuture integer-reply the length of the list after the insert operation, or `-1` when the value `pivot` + * was not found. + */ RedisFuture linsert(K key, boolean before, V pivot, V value); + /** + * Get the length of a list. + * + * @param key the key + * @return RedisFuture integer-reply the length of the list at `key`. + */ RedisFuture llen(K key); - RedisFuture lpop(K key); - + /** + * Remove and get the first element in a list. + * + * @param key the key + * @return RedisFuture bulk-string-reply the value of the first element, or `nil` when `key` does not exist. + */ + RedisFuture lpop(K key); + + /** + * Prepend one or multiple values to a list. + * + * @param key the key + * @param values the value type: value + * @return RedisFuture integer-reply the length of the list after the push operations. + */ RedisFuture lpush(K key, V... values); + /** + * Prepend a value to a list, only if the list exists. + * + * @param key the key + * @param value the value type: value + * @return RedisFuture integer-reply the length of the list after the push operation. + */ RedisFuture lpushx(K key, V value); + /** + * Get a range of elements from a list. + * + * @param key the key + * @param start the start type: long + * @param stop the stop type: long + * @return RedisFuture> array-reply list of elements in the specified range. + */ RedisFuture> lrange(K key, long start, long stop); + /** + * Get a range of elements from a list. + * + * @return RedisFuture array-reply list of elements in the specified range. + */ RedisFuture lrange(ValueStreamingChannel channel, K key, long start, long stop); + /** + * Remove elements from a list. + * + * @param key the key + * @param count the count type: long + * @param value the value type: value + * @return RedisFuture integer-reply the number of removed elements. + */ RedisFuture lrem(K key, long count, V value); + /** + * Set the value of an element in a list by its index. + * + * @param key the key + * @param index the index type: long + * @param value the value type: value + * @return RedisFuture simple-string-reply + */ RedisFuture lset(K key, long index, V value); + /** + * Trim a list to the specified range. + * + * @param key the key + * @param start the start type: long + * @param stop the stop type: long + * @return RedisFuture simple-string-reply + */ RedisFuture ltrim(K key, long start, long stop); + /** + * Remove and get the last element in a list. + * + * @param key the key + * @return RedisFuture bulk-string-reply the value of the last element, or `nil` when `key` does not exist. + */ RedisFuture rpop(K key); + /** + * Remove the last element in a list, append it to another list and return it. + * + * @param source the source type: key + * @param destination the destination type: key + * @return RedisFuture bulk-string-reply the element being popped and pushed. + */ RedisFuture rpoplpush(K source, K destination); + /** + * Append one or multiple values to a list. + * + * @param key the key + * @param values the value type: value + * @return RedisFuture integer-reply the length of the list after the push operation. + */ RedisFuture rpush(K key, V... values); + /** + * Append a value to a list, only if the list exists. + * @param key the key + * @param value the value type: value + * @return RedisFuture integer-reply the length of the list after the push operation. + */ RedisFuture rpushx(K key, V value); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java index e0e44760c0..d23b9c2c75 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java @@ -14,39 +14,177 @@ * @since 17.05.14 21:14 */ public interface RedisListsConnection { + /** + * Remove and get the first element in a list, or block until one is available. + * + * @param timeout the key + * @param keys the timeout type: long + * @return KeyValue array-reply specifically: + * + * A `nil` multi-bulk when no element could be popped and the timeout expired. A two-element multi-bulk with the + * first element being the name of the key where an element was popped and the second element being the value of the + * popped element. + */ KeyValue blpop(long timeout, K... keys); + /** + * Remove and get the last element in a list, or block until one is available. + * + * @param timeout the key + * @param keys the timeout type: long + * @return KeyValue array-reply specifically: + * + * A `nil` multi-bulk when no element could be popped and the timeout expired. A two-element multi-bulk with the + * first element being the name of the key where an element was popped and the second element being the value of the + * popped element. + */ KeyValue brpop(long timeout, K... keys); + /** + * Pop a value from a list, push it to another list and return it; or block until one is available. + * + * @param timeout the source type: key + * @param source the destination type: key + * @param destination the timeout type: long + * @return V bulk-string-reply the element being popped from `source` and pushed to `destination`. If `timeout` is reached, + * a + */ V brpoplpush(long timeout, K source, K destination); + /** + * Get an element from a list by its index. + * + * @param key the key + * @param index the index type: long + * @return V bulk-string-reply the requested element, or `nil` when `index` is out of range. + */ V lindex(K key, long index); + /** + * Insert an element before or after another element in a list. + * + * @param key the key + * @param before the where type: enum + * @param pivot the pivot type: value + * @param value the value type: value + * @return Long integer-reply the length of the list after the insert operation, or `-1` when the value `pivot` was not + * found. + */ Long linsert(K key, boolean before, V pivot, V value); + /** + * Get the length of a list. + * + * @param key the key + * @return Long integer-reply the length of the list at `key`. + */ Long llen(K key); + /** + * Remove and get the first element in a list. + * + * @param key the key + * @return V bulk-string-reply the value of the first element, or `nil` when `key` does not exist. + */ V lpop(K key); + /** + * Prepend one or multiple values to a list. + * + * @param key the key + * @param values the value type: value + * @return Long integer-reply the length of the list after the push operations. + */ Long lpush(K key, V... values); + /** + * Prepend a value to a list, only if the list exists. + * + * @param key the key + * @param value the value type: value + * @return Long integer-reply the length of the list after the push operation. + */ Long lpushx(K key, V value); + /** + * Get a range of elements from a list. + * + * @param key the key + * @param start the start type: long + * @param stop the stop type: long + * @return List array-reply list of elements in the specified range. + */ List lrange(K key, long start, long stop); + /** + * Get a range of elements from a list. + * + * @return Long array-reply list of elements in the specified range. + */ Long lrange(ValueStreamingChannel channel, K key, long start, long stop); + /** + * Remove elements from a list. + * + * @param key the key + * @param count the count type: long + * @param value the value type: value + * @return Long integer-reply the number of removed elements. + */ Long lrem(K key, long count, V value); + /** + * Set the value of an element in a list by its index. + * + * @param key the key + * @param index the index type: long + * @param value the value type: value + * @return String simple-string-reply + */ String lset(K key, long index, V value); + /** + * Trim a list to the specified range. + * + * @param key the key + * @param start the start type: long + * @param stop the stop type: long + * @return String simple-string-reply + */ String ltrim(K key, long start, long stop); + /** + * Remove and get the last element in a list. + * + * @param key the key + * @return V bulk-string-reply the value of the last element, or `nil` when `key` does not exist. + */ V rpop(K key); + /** + * Remove the last element in a list, append it to another list and return it. + * + * @param source the source type: key + * @param destination the destination type: key + * @return V bulk-string-reply the element being popped and pushed. + */ V rpoplpush(K source, K destination); + /** + * Append one or multiple values to a list. + * + * @param key the key + * @param values the value type: value + * @return Long integer-reply the length of the list after the push operation. + */ Long rpush(K key, V... values); + /** + * Append a value to a list, only if the list exists. + * + * @param key the key + * @param value the value type: value + * @return Long integer-reply the length of the list after the push operation. + */ Long rpushx(K key, V value); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingAsyncConnection.java index bc7ad5e486..79fd9a4e1e 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingAsyncConnection.java @@ -11,12 +11,34 @@ * @since 17.05.14 21:28 */ public interface RedisScriptingAsyncConnection { + /** + * Execute a Lua script server side. + */ RedisFuture eval(String script, ScriptOutputType type, K... keys); + /** + * Execute a Lua script server side. + * + * @param script the script type: string + * @param type the numkeys type: long + * @param keys the key + * @param values the arg type: value + */ RedisFuture eval(String script, ScriptOutputType type, K[] keys, V... values); + /** + * Execute a Lua script server side. + */ RedisFuture evalsha(String digest, ScriptOutputType type, K... keys); + /** + * Execute a Lua script server side. + * + * @param digest the sha1 type: string + * @param type the numkeys type: long + * @param keys the key + * @param values the arg type: value + */ RedisFuture evalsha(String digest, ScriptOutputType type, K[] keys, V... values); RedisFuture> scriptExists(String... digests); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingConnection.java index cd68195467..b20b78ad27 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisScriptingConnection.java @@ -11,12 +11,34 @@ * @since 17.05.14 21:28 */ public interface RedisScriptingConnection { + /** + * Execute a Lua script server side. + */ T eval(String script, ScriptOutputType type, K... keys); + /** + * Execute a Lua script server side. + * + * @param script the script type: string + * @param type the numkeys type: long + * @param keys the key + * @param values the arg type: value + */ T eval(String script, ScriptOutputType type, K[] keys, V... values); + /** + * Execute a Lua script server side. + */ T evalsha(String digest, ScriptOutputType type, K... keys); + /** + * Execute a Lua script server side. + * + * @param digest the sha1 type: string + * @param type the numkeys type: long + * @param keys the key + * @param values the arg type: value + */ T evalsha(String digest, ScriptOutputType type, K[] keys, V... values); List scriptExists(String... digests); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisSentinelAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisSentinelAsyncConnection.java index 981b3136a8..00d096a6b3 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisSentinelAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisSentinelAsyncConnection.java @@ -14,22 +14,66 @@ * @since 15.05.14 21:04 */ public interface RedisSentinelAsyncConnection extends Closeable { + + /** + * Return the ip and port number of the master with that name. + * + * @param key + * @return Future + */ Future getMasterAddrByName(K key); + /** + * Show the state and info of the specified master. + * + * @param key + * @return + */ RedisFuture> master(K key); + /** + * Provides a list of slaves for the master with the specified name. + * + * @param key + * @return + */ RedisFuture> slaves(K key); + /** + * This command will reset all the masters with matching name. + * + * @param key + * @return + */ RedisFuture reset(K key); RedisFuture failover(K key); + /** + * This command tells the Sentinel to start monitoring a new master with the specified name, ip, port, and quorum. + */ RedisFuture monitor(K key, String ip, int port, int quorum); + /** + * Multiple option / value pairs can be specified (or none at all). + * + * @return RedisFuture simple-string-reply `OK` if `SET` was executed correctly. + */ RedisFuture set(K key, String option, V value); + /** + * remove the specified master. + * + * @param key + * @return + */ RedisFuture remove(K key); + /** + * Ping the server. + * + * @return RedisFuture simple-string-reply + */ RedisFuture ping(); @Override diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisServerAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisServerAsyncConnection.java index 22049c5bb6..4e1ed7a0a1 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisServerAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisServerAsyncConnection.java @@ -12,8 +12,18 @@ * @since 17.05.14 21:32 */ public interface RedisServerAsyncConnection { + /** + * Asynchronously rewrite the append-only file. + * + * @return RedisFuture simple-string-reply always `OK`. + */ RedisFuture bgrewriteaof(); + /** + * Asynchronously save the dataset to disk. + * + * @return RedisFuture simple-string-reply + */ RedisFuture bgsave(); RedisFuture clientGetname(); @@ -34,26 +44,72 @@ public interface RedisServerAsyncConnection { RedisFuture configSet(String parameter, String value); + /** + * Return the number of keys in the selected database. + * + * @return RedisFuture integer-reply + */ RedisFuture dbsize(); RedisFuture debugObject(K key); void debugSegfault(); + /** + * Remove all keys from all databases. + * + * @return RedisFuture simple-string-reply + */ RedisFuture flushall(); + /** + * Remove all keys from the current database. + * + * @return RedisFuture simple-string-reply + */ RedisFuture flushdb(); + /** + * Get information and statistics about the server. + * + * @return RedisFuture bulk-string-reply as a collection of text lines. + */ RedisFuture info(); + /** + * Get information and statistics about the server. + * + * @param section the section type: string + * @return RedisFuture bulk-string-reply as a collection of text lines. + */ RedisFuture info(String section); + /** + * Get the UNIX time stamp of the last successful save to disk. + * + * @return RedisFuture integer-reply an UNIX time stamp. + */ RedisFuture lastsave(); + /** + * Synchronously save the dataset to disk. + * + * @return RedisFuture simple-string-reply The commands returns OK on success. + */ RedisFuture save(); + /** + * Synchronously save the dataset to disk and then shut down the server. + */ void shutdown(boolean save); + /** + * Make the server a slave of another instance, or promote it as master. + * + * @param host the host type: string + * @param port the port type: string + * @return RedisFuture simple-string-reply + */ RedisFuture slaveof(String host, int port); RedisFuture slaveofNoOne(); @@ -66,7 +122,19 @@ public interface RedisServerAsyncConnection { RedisFuture slowlogReset(); + /** + * Internal command used for replication. + */ RedisFuture sync(); + /** + * Return the current server time. + * + * @return RedisFuture> array-reply specifically: + * + * A multi bulk reply containing two elements: + * + * unix time in seconds. microseconds. + */ RedisFuture> time(); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisServerConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisServerConnection.java index 699af35fa3..7b1a4d6efe 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisServerConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisServerConnection.java @@ -12,8 +12,18 @@ * @since 17.05.14 21:32 */ public interface RedisServerConnection { + /** + * Asynchronously rewrite the append-only file. + * + * @return String simple-string-reply always `OK`. + */ String bgrewriteaof(); + /** + * Asynchronously save the dataset to disk. + * + * @return String simple-string-reply + */ String bgsave(); K clientGetname(); @@ -34,26 +44,72 @@ public interface RedisServerConnection { String configSet(String parameter, String value); + /** + * Return the number of keys in the selected database. + * + * @return Long integer-reply + */ Long dbsize(); String debugObject(K key); void debugSegfault(); + /** + * Remove all keys from all databases. + * + * @return String simple-string-reply + */ String flushall(); + /** + * Remove all keys from the current database. + * + * @return String simple-string-reply + */ String flushdb(); + /** + * Get information and statistics about the server. + * + * @return String bulk-string-reply as a collection of text lines. + */ String info(); + /** + * Get information and statistics about the server. + * + * @param section the section type: string + * @return String bulk-string-reply as a collection of text lines. + */ String info(String section); + /** + * Get the UNIX time stamp of the last successful save to disk. + * + * @return Date integer-reply an UNIX time stamp. + */ Date lastsave(); + /** + * Synchronously save the dataset to disk. + * + * @return String simple-string-reply The commands returns OK on success. + */ String save(); + /** + * Synchronously save the dataset to disk and then shut down the server. + */ void shutdown(boolean save); + /** + * Make the server a slave of another instance, or promote it as master. + * + * @param host the host type: string + * @param port the port type: string + * @return String simple-string-reply + */ String slaveof(String host, int port); String slaveofNoOne(); @@ -66,7 +122,19 @@ public interface RedisServerConnection { String slowlogReset(); + /** + * Internal command used for replication. + */ String sync(); + /** + * Return the current server time. + * + * @return List array-reply specifically: + * + * A multi bulk reply containing two elements: + * + * unix time in seconds. microseconds. + */ List time(); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsAsyncConnection.java index c4c42d2a9c..e22815aaa7 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsAsyncConnection.java @@ -13,59 +13,221 @@ * @since 17.05.14 21:16 */ public interface RedisSetsAsyncConnection { + /** + * Add one or more members to a set. + * + * @param key the key + * @param members the member type: value + * @return RedisFuture integer-reply the number of elements that were added to the set, not including all the elements + * already present into the set. + */ RedisFuture sadd(K key, V... members); + /** + * Get the number of members in a set. + * + * @param key the key + * @return RedisFuture integer-reply the cardinality (number of elements) of the set, or `0` if `key` does not exist. + */ RedisFuture scard(K key); + /** + * Subtract multiple sets. + * + * @param keys the key + * @return RedisFuture> array-reply list with members of the resulting set. + */ RedisFuture> sdiff(K... keys); + /** + * Subtract multiple sets. + * + * @return RedisFuture array-reply list with members of the resulting set. + */ RedisFuture sdiff(ValueStreamingChannel channel, K... keys); + /** + * Subtract multiple sets and store the resulting set in a key. + * + * @param destination the destination type: key + * @param keys the key + * @return RedisFuture integer-reply the number of elements in the resulting set. + */ RedisFuture sdiffstore(K destination, K... keys); + /** + * Intersect multiple sets. + * + * @param keys the key + * @return RedisFuture> array-reply list with members of the resulting set. + */ RedisFuture> sinter(K... keys); + /** + * Intersect multiple sets. + * + * @return RedisFuture array-reply list with members of the resulting set. + */ RedisFuture sinter(ValueStreamingChannel channel, K... keys); + /** + * Intersect multiple sets and store the resulting set in a key. + * + * @param destination the destination type: key + * @param keys the key + * @return RedisFuture integer-reply the number of elements in the resulting set. + */ RedisFuture sinterstore(K destination, K... keys); + /** + * Determine if a given value is a member of a set. + * + * @param key the key + * @param member the member type: value + * @return RedisFuture integer-reply specifically: + * + * `1` if the element is a member of the set. `0` if the element is not a member of the set, or if `key` does not + * exist. + */ RedisFuture sismember(K key, V member); + /** + * Move a member from one set to another. + * + * @param source the source type: key + * @param destination the destination type: key + * @param member the member type: value + * @return RedisFuture integer-reply specifically: + * + * `1` if the element is moved. `0` if the element is not a member of `source` and no operation was performed. + */ RedisFuture smove(K source, K destination, V member); + /** + * Get all the members in a set. + * + * @param key the key + * @return RedisFuture> array-reply all elements of the set. + */ RedisFuture> smembers(K key); + /** + * Get all the members in a set. + * + * @return RedisFuture array-reply all elements of the set. + */ RedisFuture smembers(ValueStreamingChannel channel, K key); + /** + * Remove and return a random member from a set. + * + * @param key the key + * @return RedisFuture bulk-string-reply the removed element, or `nil` when `key` does not exist. + */ RedisFuture spop(K key); + /** + * Get one or multiple random members from a set. + * + * @return RedisFuture bulk-string-reply without the additional `count` argument the command returns a Bulk Reply with + * the randomly selected element, or `nil` when `key` does not exist. + */ RedisFuture srandmember(K key); + /** + * Get one or multiple random members from a set. + * + * @param key the key + * @param count the count type: long + * @return RedisFuture> bulk-string-reply without the additional `count` argument the command returns a Bulk Reply + * with the randomly selected element, or `nil` when `key` does not exist. + */ RedisFuture> srandmember(K key, long count); + /** + * Get one or multiple random members from a set. + * + * @return RedisFuture bulk-string-reply without the additional `count` argument the command returns a Bulk Reply with + * the randomly selected element, or `nil` when `key` does not exist. + */ RedisFuture srandmember(ValueStreamingChannel channel, K key, long count); + /** + * Remove one or more members from a set. + * + * @param key the key + * @param members the member type: value + * @return RedisFuture integer-reply the number of members that were removed from the set, not including non existing + * members. + */ RedisFuture srem(K key, V... members); + /** + * Add multiple sets. + * + * @param keys the key + * @return RedisFuture> array-reply list with members of the resulting set. + */ RedisFuture> sunion(K... keys); + /** + * Add multiple sets. + * + * @return RedisFuture array-reply list with members of the resulting set. + */ RedisFuture sunion(ValueStreamingChannel channel, K... keys); + /** + * Add multiple sets and store the resulting set in a key. + * + * @param destination the destination type: key + * @param keys the key + * @return RedisFuture integer-reply the number of elements in the resulting set. + */ RedisFuture sunionstore(K destination, K... keys); + /** + * Incrementally iterate Set elements. + */ RedisFuture> sscan(K key); + /** + * Incrementally iterate Set elements. + */ RedisFuture> sscan(K key, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + */ RedisFuture> sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + */ RedisFuture> sscan(K key, ScanCursor scanCursor); + /** + * Incrementally iterate Set elements. + */ RedisFuture sscan(ValueStreamingChannel channel, K key); + /** + * Incrementally iterate Set elements. + */ RedisFuture sscan(ValueStreamingChannel channel, K key, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + * + * @param channel + * @param key the key + * @param scanCursor the cursor type: long + * @param scanArgs + */ RedisFuture sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + */ RedisFuture sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsConnection.java index 84c9edf80e..926f3418aa 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisSetsConnection.java @@ -13,59 +13,220 @@ * @since 17.05.14 21:16 */ public interface RedisSetsConnection { + /** + * Add one or more members to a set. + * + * @param key the key + * @param members the member type: value + * @return Long integer-reply the number of elements that were added to the set, not including all the elements already + * present into the set. + */ Long sadd(K key, V... members); + /** + * Get the number of members in a set. + * + * @param key the key + * @return Long integer-reply the cardinality (number of elements) of the set, or `0` if `key` does not exist. + */ Long scard(K key); + /** + * Subtract multiple sets. + * + * @param keys the key + * @return Set array-reply list with members of the resulting set. + */ Set sdiff(K... keys); + /** + * Subtract multiple sets. + * + * @return Long array-reply list with members of the resulting set. + */ Long sdiff(ValueStreamingChannel channel, K... keys); + /** + * Subtract multiple sets and store the resulting set in a key. + * + * @param destination the destination type: key + * @param keys the key + * @return Long integer-reply the number of elements in the resulting set. + */ Long sdiffstore(K destination, K... keys); + /** + * Intersect multiple sets. + * + * @param keys the key + * @return Set array-reply list with members of the resulting set. + */ Set sinter(K... keys); + /** + * Intersect multiple sets. + * + * @return Long array-reply list with members of the resulting set. + */ Long sinter(ValueStreamingChannel channel, K... keys); + /** + * Intersect multiple sets and store the resulting set in a key. + * + * @param destination the destination type: key + * @param keys the key + * @return Long integer-reply the number of elements in the resulting set. + */ Long sinterstore(K destination, K... keys); + /** + * Determine if a given value is a member of a set. + * + * @param key the key + * @param member the member type: value + * @return Boolean integer-reply specifically: + * + * `1` if the element is a member of the set. `0` if the element is not a member of the set, or if `key` does not + * exist. + */ Boolean sismember(K key, V member); + /** + * Move a member from one set to another. + * + * @param source the source type: key + * @param destination the destination type: key + * @param member the member type: value + * @return Boolean integer-reply specifically: + * + * `1` if the element is moved. `0` if the element is not a member of `source` and no operation was performed. + */ Boolean smove(K source, K destination, V member); + /** + * Get all the members in a set. + * + * @param key the key + * @return Set array-reply all elements of the set. + */ Set smembers(K key); + /** + * Get all the members in a set. + * + * @return Long array-reply all elements of the set. + */ Long smembers(ValueStreamingChannel channel, K key); + /** + * Remove and return a random member from a set. + * + * @param key the key + * @return V bulk-string-reply the removed element, or `nil` when `key` does not exist. + */ V spop(K key); + /** + * Get one or multiple random members from a set. + * + * @return V bulk-string-reply without the additional `count` argument the command returns a Bulk Reply with the randomly + * selected element, or `nil` when `key` does not exist. + */ V srandmember(K key); + /** + * Get one or multiple random members from a set. + * + * @param key the key + * @param count the count type: long + * @return Set bulk-string-reply without the additional `count` argument the command returns a Bulk Reply with the + * randomly selected element, or `nil` when `key` does not exist. + */ Set srandmember(K key, long count); + /** + * Get one or multiple random members from a set. + * + * @return Long bulk-string-reply without the additional `count` argument the command returns a Bulk Reply with the randomly + * selected element, or `nil` when `key` does not exist. + */ Long srandmember(ValueStreamingChannel channel, K key, long count); + /** + * Remove one or more members from a set. + * + * @param key the key + * @param members the member type: value + * @return Long integer-reply the number of members that were removed from the set, not including non existing members. + */ Long srem(K key, V... members); + /** + * Add multiple sets. + * + * @param keys the key + * @return Set array-reply list with members of the resulting set. + */ Set sunion(K... keys); + /** + * Add multiple sets. + * + * @return Long array-reply list with members of the resulting set. + */ Long sunion(ValueStreamingChannel channel, K... keys); + /** + * Add multiple sets and store the resulting set in a key. + * + * @param destination the destination type: key + * @param keys the key + * @return Long integer-reply the number of elements in the resulting set. + */ Long sunionstore(K destination, K... keys); + /** + * Incrementally iterate Set elements. + */ ValueScanCursor sscan(K key); + /** + * Incrementally iterate Set elements. + */ ValueScanCursor sscan(K key, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + */ ValueScanCursor sscan(K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + */ ValueScanCursor sscan(K key, ScanCursor scanCursor); + /** + * Incrementally iterate Set elements. + */ StreamScanCursor sscan(ValueStreamingChannel channel, K key); + /** + * Incrementally iterate Set elements. + */ StreamScanCursor sscan(ValueStreamingChannel channel, K key, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + * + * @param channel + * @param key the key + * @param scanCursor the cursor type: long + * @param scanArgs + */ StreamScanCursor sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate Set elements. + */ StreamScanCursor sscan(ValueStreamingChannel channel, K key, ScanCursor scanCursor); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsAsyncConnection.java index 25ab90729a..07ddecfaad 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsAsyncConnection.java @@ -14,38 +14,127 @@ * @since 17.05.14 21:18 */ public interface RedisSortedSetsAsyncConnection { + /** + * Add one or more members to a sorted set, or update its score if it already exists. + * + * @return RedisFuture integer-reply specifically: + * + * The number of elements added to the sorted sets, not including elements already existing for which the score was + * updated. + */ RedisFuture zadd(K key, double score, V member); /** + * Add one or more members to a sorted set, or update its score if it already exists. + * + * @param key the key + * @param scoresAndValues the null + * @return RedisFuture integer-reply specifically: * - * @param key - * @param scoresAndValues tuples with (double) score, (V) value - * @return RedisFuture + * The number of elements added to the sorted sets, not including elements already existing for which the score was + * updated. */ RedisFuture zadd(K key, Object... scoresAndValues); + /** + * Get the number of members in a sorted set. + * + * @param key the key + * @return RedisFuture integer-reply the cardinality (number of elements) of the sorted set, or `0` if `key` does not + * exist. + */ RedisFuture zcard(K key); + /** + * Count the members in a sorted set with scores within the given values. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return RedisFuture integer-reply the number of elements in the specified score range. + */ RedisFuture zcount(K key, double min, double max); + /** + * Count the members in a sorted set with scores within the given values. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return RedisFuture integer-reply the number of elements in the specified score range. + */ RedisFuture zcount(K key, String min, String max); + /** + * Increment the score of a member in a sorted set. + * + * @param key the key + * @param amount the increment type: long + * @param member the member type: key + * @return RedisFuture bulk-string-reply the new score of `member` (a double precision floating point number), + * represented as string. + */ RedisFuture zincrby(K key, double amount, K member); + /** + * Intersect multiple sorted sets and store the resulting sorted set in a new key. + * + * @return RedisFuture integer-reply the number of elements in the resulting sorted set at `destination`. + */ RedisFuture zinterstore(K destination, K... keys); + /** + * Intersect multiple sorted sets and store the resulting sorted set in a new key. + * + * @return RedisFuture integer-reply the number of elements in the resulting sorted set at `destination`. + */ RedisFuture zinterstore(K destination, ZStoreArgs storeArgs, K... keys); + /** + * Return a range of members in a sorted set, by index. + * + * @return RedisFuture> array-reply list of elements in the specified range (optionally with their scores). + */ RedisFuture> zrange(K key, long start, long stop); RedisFuture>> zrangeWithScores(K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score. + * + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrangebyscore(K key, double min, double max); + /** + * Return a range of members in a sorted set, by score. + * + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrangebyscore(K key, String min, String max); + /** + * Return a range of members in a sorted set, by score. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @param offset the withscores type: enum + * @param count the null + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrangebyscore(K key, double min, double max, long offset, long count); + /** + * Return a range of members in a sorted set, by score. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @param offset the withscores type: enum + * @param count the null + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrangebyscore(K key, String min, String max, long offset, long count); RedisFuture>> zrangebyscoreWithScores(K key, double min, double max); @@ -56,16 +145,45 @@ public interface RedisSortedSetsAsyncConnection { RedisFuture>> zrangebyscoreWithScores(K key, String min, String max, long offset, long count); + /** + * Return a range of members in a sorted set, by index. + * + * @param channel the key + * @param key the start type: long + * @param start the stop type: long + * @param stop the withscores type: enum + * @return RedisFuture array-reply list of elements in the specified range (optionally with their scores). + */ RedisFuture zrange(ValueStreamingChannel channel, K key, long start, long stop); RedisFuture zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrangebyscore(ValueStreamingChannel channel, K key, double min, double max); + /** + * Return a range of members in a sorted set, by score. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrangebyscore(ValueStreamingChannel channel, K key, String min, String max); + /** + * Return a range of members in a sorted set, by score. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrangebyscore(ValueStreamingChannel channel, K key, double min, double max, long offset, long count); + /** + * Return a range of members in a sorted set, by score. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrangebyscore(ValueStreamingChannel channel, K key, String min, String max, long offset, long count); RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max); @@ -78,26 +196,102 @@ RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max, long offset, long count); + /** + * Determine the index of a member in a sorted set. + * + * @param key the key + * @param member the member type: value + * @return RedisFuture integer-reply the rank of `member`. If `member` does not exist in the sorted set or `key` does + * not exist, + */ RedisFuture zrank(K key, V member); + /** + * Remove one or more members from a sorted set. + * + * @param key the key + * @param members the member type: value + * @return RedisFuture integer-reply specifically: + * + * The number of members removed from the sorted set, not including non existing members. + */ RedisFuture zrem(K key, V... members); + /** + * Remove all members in a sorted set within the given indexes. + * + * @param key the key + * @param start the start type: long + * @param stop the stop type: long + * @return RedisFuture integer-reply the number of elements removed. + */ RedisFuture zremrangebyrank(K key, long start, long stop); + /** + * Remove all members in a sorted set within the given scores. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return RedisFuture integer-reply the number of elements removed. + */ RedisFuture zremrangebyscore(K key, double min, double max); + /** + * Remove all members in a sorted set within the given scores. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return RedisFuture integer-reply the number of elements removed. + */ RedisFuture zremrangebyscore(K key, String min, String max); + /** + * Return a range of members in a sorted set, by index, with scores ordered from high to low. + * + * @return RedisFuture> array-reply list of elements in the specified range (optionally with their scores). + */ RedisFuture> zrevrange(K key, long start, long stop); RedisFuture>> zrevrangeWithScores(K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrevrangebyscore(K key, double max, double min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrevrangebyscore(K key, String max, String min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @param key the key + * @param max the max type: double + * @param min the min type: double + * @param offset the withscores type: enum + * @param count the null + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrevrangebyscore(K key, double max, double min, long offset, long count); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @param key the key + * @param max the max type: double + * @param min the min type: double + * @param offset the withscores type: enum + * @param count the null + * @return RedisFuture> array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture> zrevrangebyscore(K key, String max, String min, long offset, long count); RedisFuture>> zrevrangebyscoreWithScores(K key, double max, double min); @@ -108,16 +302,45 @@ RedisFuture zrangebyscoreWithScores(ScoredValueStreamingChannel channel RedisFuture>> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count); + /** + * Return a range of members in a sorted set, by index, with scores ordered from high to low. + * + * @param channel the key + * @param key the start type: long + * @param start the stop type: long + * @param stop the withscores type: enum + * @return RedisFuture array-reply list of elements in the specified range (optionally with their scores). + */ RedisFuture zrevrange(ValueStreamingChannel channel, K key, long start, long stop); RedisFuture zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min, long offset, long count); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return RedisFuture array-reply list of elements in the specified score range (optionally with their scores). + */ RedisFuture zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min, long offset, long count); RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min); @@ -130,35 +353,116 @@ RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel chan RedisFuture zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min, long offset, long count); + /** + * Determine the index of a member in a sorted set, with scores ordered from high to low. + * + * @param key the key + * @param member the member type: value + * @return RedisFuture integer-reply the rank of `member`. If `member` does not exist in the sorted set or `key` does + * not exist, + */ RedisFuture zrevrank(K key, V member); + /** + * Get the score associated with the given member in a sorted set. + * + * @param key the key + * @param member the member type: value + * @return RedisFuture bulk-string-reply the score of `member` (a double precision floating point number), + * represented as string. + */ RedisFuture zscore(K key, V member); + /** + * Add multiple sorted sets and store the resulting sorted set in a new key. + * + * @return RedisFuture integer-reply the number of elements in the resulting sorted set at `destination`. + */ RedisFuture zunionstore(K destination, K... keys); + /** + * Add multiple sorted sets and store the resulting sorted set in a new key. + * + * @return RedisFuture integer-reply the number of elements in the resulting sorted set at `destination`. + */ RedisFuture zunionstore(K destination, ZStoreArgs storeArgs, K... keys); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture> zscan(K key); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture> zscan(K key, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture> zscan(K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture> zscan(K key, ScanCursor scanCursor); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture zscan(ScoredValueStreamingChannel channel, K key); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture zscan(ScoredValueStreamingChannel channel, K key, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + * + * @param channel + * @param key the key + * @param scanCursor the cursor type: long + * @param scanArgs + */ RedisFuture zscan(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ RedisFuture zscan(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor); + /** + * Count the number of members in a sorted set between a given lexicographical range. + * + * @param key the key + * @param min the min type: string + * @param max the max type: string + * @return RedisFuture integer-reply the number of elements in the specified score range. + */ RedisFuture zlexcount(K key, String min, String max); + /** + * Remove all members in a sorted set between the given lexicographical range. + * + * @param key the key + * @param min the min type: string + * @param max the max type: string + * @return RedisFuture integer-reply the number of elements removed. + */ RedisFuture zremrangebylex(K key, String min, String max); + /** + * Return a range of members in a sorted set, by lexicographical range. + * + * @return RedisFuture> array-reply list of elements in the specified score range. + */ RedisFuture> zrangebylex(K key, String min, String max); + /** + * Return a range of members in a sorted set, by lexicographical range. + * + * @return RedisFuture> array-reply list of elements in the specified score range. + */ RedisFuture> zrangebylex(K key, String min, String max, long offset, long count); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsConnection.java index c7e5005480..f7fceca3cf 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisSortedSetsConnection.java @@ -14,38 +14,126 @@ * @since 17.05.14 21:18 */ public interface RedisSortedSetsConnection { + /** + * Add one or more members to a sorted set, or update its score if it already exists. + * + * @return Long integer-reply specifically: + * + * The number of elements added to the sorted sets, not including elements already existing for which the score was + * updated. + */ Long zadd(K key, double score, V member); /** + * Add one or more members to a sorted set, or update its score if it already exists. + * + * @param key the key + * @param scoresAndValues the null + * @return Long integer-reply specifically: * - * @param key - * @param scoresAndValues tuples with (double) score, (V) value - * @return Long + * The number of elements added to the sorted sets, not including elements already existing for which the score was + * updated. */ Long zadd(K key, Object... scoresAndValues); + /** + * Get the number of members in a sorted set. + * + * @param key the key + * @return Long integer-reply the cardinality (number of elements) of the sorted set, or `0` if `key` does not exist. + */ Long zcard(K key); + /** + * Count the members in a sorted set with scores within the given values. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return Long integer-reply the number of elements in the specified score range. + */ Long zcount(K key, double min, double max); + /** + * Count the members in a sorted set with scores within the given values. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return Long integer-reply the number of elements in the specified score range. + */ Long zcount(K key, String min, String max); + /** + * Increment the score of a member in a sorted set. + * + * @param key the key + * @param amount the increment type: long + * @param member the member type: key + * @return Double bulk-string-reply the new score of `member` (a double precision floating point number), represented as + * string. + */ Double zincrby(K key, double amount, K member); + /** + * Intersect multiple sorted sets and store the resulting sorted set in a new key. + * + * @return Long integer-reply the number of elements in the resulting sorted set at `destination`. + */ Long zinterstore(K destination, K... keys); + /** + * Intersect multiple sorted sets and store the resulting sorted set in a new key. + * + * @return Long integer-reply the number of elements in the resulting sorted set at `destination`. + */ Long zinterstore(K destination, ZStoreArgs storeArgs, K... keys); + /** + * Return a range of members in a sorted set, by index. + * + * @return List array-reply list of elements in the specified range (optionally with their scores). + */ List zrange(K key, long start, long stop); List> zrangeWithScores(K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score. + * + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrangebyscore(K key, double min, double max); + /** + * Return a range of members in a sorted set, by score. + * + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrangebyscore(K key, String min, String max); + /** + * Return a range of members in a sorted set, by score. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @param offset the withscores type: enum + * @param count the null + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrangebyscore(K key, double min, double max, long offset, long count); + /** + * Return a range of members in a sorted set, by score. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @param offset the withscores type: enum + * @param count the null + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrangebyscore(K key, String min, String max, long offset, long count); List> zrangebyscoreWithScores(K key, double min, double max); @@ -56,16 +144,45 @@ public interface RedisSortedSetsConnection { List> zrangebyscoreWithScores(K key, String min, String max, long offset, long count); + /** + * Return a range of members in a sorted set, by index. + * + * @param channel the key + * @param key the start type: long + * @param start the stop type: long + * @param stop the withscores type: enum + * @return Long array-reply list of elements in the specified range (optionally with their scores). + */ Long zrange(ValueStreamingChannel channel, K key, long start, long stop); Long zrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score. + * + * @return Long array-reply list of elements in the specified score range (optionally with their scores). + */ Long zrangebyscore(ValueStreamingChannel channel, K key, double min, double max); + /** + * Return a range of members in a sorted set, by score. + * + * @return Long array-reply list of elements in the specified score range (optionally with their scores). + */ Long zrangebyscore(ValueStreamingChannel channel, K key, String min, String max); + /** + * Return a range of members in a sorted set, by score. + * + * @return Long array-reply list of elements in the specified score range (optionally with their scores). + */ Long zrangebyscore(ValueStreamingChannel channel, K key, double min, double max, long offset, long count); + /** + * Return a range of members in a sorted set, by score. + * @return Long array-reply list of elements in the specified score range (optionally + with their scores). + */ Long zrangebyscore(ValueStreamingChannel channel, K key, String min, String max, long offset, long count); Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double min, double max); @@ -76,26 +193,101 @@ public interface RedisSortedSetsConnection { Long zrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String min, String max, long offset, long count); + /** + * Determine the index of a member in a sorted set. + * + * @param key the key + * @param member the member type: value + * @return Long integer-reply the rank of `member`. If `member` does not exist in the sorted set or `key` does not exist, + */ Long zrank(K key, V member); + /** + * Remove one or more members from a sorted set. + * + * @param key the key + * @param members the member type: value + * @return Long integer-reply specifically: + * + * The number of members removed from the sorted set, not including non existing members. + */ Long zrem(K key, V... members); + /** + * Remove all members in a sorted set within the given indexes. + * + * @param key the key + * @param start the start type: long + * @param stop the stop type: long + * @return Long integer-reply the number of elements removed. + */ Long zremrangebyrank(K key, long start, long stop); + /** + * Remove all members in a sorted set within the given scores. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return Long integer-reply the number of elements removed. + */ Long zremrangebyscore(K key, double min, double max); + /** + * Remove all members in a sorted set within the given scores. + * + * @param key the key + * @param min the min type: double + * @param max the max type: double + * @return Long integer-reply the number of elements removed. + */ Long zremrangebyscore(K key, String min, String max); + /** + * Return a range of members in a sorted set, by index, with scores ordered from high to low. + * + * @return List array-reply list of elements in the specified range (optionally with their scores). + */ List zrevrange(K key, long start, long stop); List> zrevrangeWithScores(K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrevrangebyscore(K key, double max, double min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrevrangebyscore(K key, String max, String min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @param key the key + * @param max the max type: double + * @param min the min type: double + * @param offset the withscores type: enum + * @param count the null + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrevrangebyscore(K key, double max, double min, long offset, long count); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @param key the key + * @param max the max type: double + * @param min the min type: double + * @param offset the withscores type: enum + * @param count the null + * @return List array-reply list of elements in the specified score range (optionally with their scores). + */ List zrevrangebyscore(K key, String max, String min, long offset, long count); List> zrevrangebyscoreWithScores(K key, double max, double min); @@ -106,16 +298,45 @@ public interface RedisSortedSetsConnection { List> zrevrangebyscoreWithScores(K key, String max, String min, long offset, long count); + /** + * Return a range of members in a sorted set, by index, with scores ordered from high to low. + * + * @param channel the key + * @param key the start type: long + * @param start the stop type: long + * @param stop the withscores type: enum + * @return Long array-reply list of elements in the specified range (optionally with their scores). + */ Long zrevrange(ValueStreamingChannel channel, K key, long start, long stop); Long zrevrangeWithScores(ScoredValueStreamingChannel channel, K key, long start, long stop); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return Long array-reply list of elements in the specified score range (optionally with their scores). + */ Long zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return Long array-reply list of elements in the specified score range (optionally with their scores). + */ Long zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * @return Long array-reply list of elements in the specified score range (optionally + with their scores). + */ Long zrevrangebyscore(ValueStreamingChannel channel, K key, double max, double min, long offset, long count); + /** + * Return a range of members in a sorted set, by score, with scores ordered from high to low. + * + * @return Long array-reply list of elements in the specified score range (optionally with their scores). + */ Long zrevrangebyscore(ValueStreamingChannel channel, K key, String max, String min, long offset, long count); Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, double max, double min); @@ -128,35 +349,111 @@ Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, d Long zrevrangebyscoreWithScores(ScoredValueStreamingChannel channel, K key, String max, String min, long offset, long count); + /** + * Determine the index of a member in a sorted set, with scores ordered from high to low. + * + * @param key the key + * @param member the member type: value + * @return Long integer-reply the rank of `member`. If `member` does not exist in the sorted set or `key` does not exist, + */ Long zrevrank(K key, V member); + /** + * Get the score associated with the given member in a sorted set. + * + * @param key the key + * @param member the member type: value + * @return Double bulk-string-reply the score of `member` (a double precision floating point number), represented as string. + */ Double zscore(K key, V member); + /** + * Add multiple sorted sets and store the resulting sorted set in a new key. + * + * @return Long integer-reply the number of elements in the resulting sorted set at `destination`. + */ Long zunionstore(K destination, K... keys); + /** + * Add multiple sorted sets and store the resulting sorted set in a new key. + * + * @return Long integer-reply the number of elements in the resulting sorted set at `destination`. + */ Long zunionstore(K destination, ZStoreArgs storeArgs, K... keys); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ ScoredValueScanCursor zscan(K key); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ ScoredValueScanCursor zscan(K key, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ ScoredValueScanCursor zscan(K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ ScoredValueScanCursor zscan(K key, ScanCursor scanCursor); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ StreamScanCursor zscan(ScoredValueStreamingChannel channel, K key); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ StreamScanCursor zscan(ScoredValueStreamingChannel channel, K key, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + * + * @param channel + * @param key the key + * @param scanCursor the cursor type: long + * @param scanArgs + */ StreamScanCursor zscan(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor, ScanArgs scanArgs); + /** + * Incrementally iterate sorted sets elements and associated scores. + */ StreamScanCursor zscan(ScoredValueStreamingChannel channel, K key, ScanCursor scanCursor); + /** + * Count the number of members in a sorted set between a given lexicographical range. + * + * @param key the key + * @param min the min type: string + * @param max the max type: string + * @return Long integer-reply the number of elements in the specified score range. + */ Long zlexcount(K key, String min, String max); + /** + * Remove all members in a sorted set between the given lexicographical range. + * @param key the key + * @param min the min type: string + * @param max the max type: string + * @return Long integer-reply the number of elements removed. + */ Long zremrangebylex(K key, String min, String max); + /** + * Return a range of members in a sorted set, by lexicographical range. + * @return List array-reply list of elements in the specified score range. + */ List zrangebylex(K key, String min, String max); + /** + * Return a range of members in a sorted set, by lexicographical range. + * @return List array-reply list of elements in the specified score range. + */ List zrangebylex(K key, String min, String max, long offset, long count); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java index 5ce16d800c..2286fd5218 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java @@ -15,14 +15,75 @@ * @since 17.05.14 21:12 */ public interface RedisStringsAsyncConnection { + /** + * Append a value to a key. + * + * @param key the key + * @param value the value type: value + * @return RedisFuture integer-reply the length of the string after the append operation. + */ RedisFuture append(K key, V value); + /** + * Count set bits in a string. + * + * @return RedisFuture integer-reply The number of bits set to 1. + */ RedisFuture bitcount(K key); + /** + * Count set bits in a string. + * + * @return RedisFuture integer-reply The number of bits set to 1. + */ RedisFuture bitcount(K key, long start, long end); + /** + * Find first bit set or clear in a string. + * + * @return RedisFuture integer-reply The command returns the position of the first bit set to 1 or 0 according to the + * request. + * + * If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is + * returned. + * + * If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns + * the first bit not part of the string on the right. So if the string is tree bytes set to the value 0xff the + * command `BITPOS key 0` will return 24, since up to bit 23 all the bits are 1. + * + * Basically the function consider the right of the string as padded with zeros if you look for clear bits and + * specify no range or the _start_ argument **only**. + * + * However this behavior changes if you are looking for clear bits and specify a range with both __start__ and + * __end__. If no clear bit is found in the specified range, the function returns -1 as the user specified a clear + * range and there are no 0 bits in that range. + */ RedisFuture bitpos(K key, boolean state); + /** + * Find first bit set or clear in a string. + * + * @param key the key + * @param state the bit type: long + * @param start the start type: long + * @param end the end type: long + * @return RedisFuture integer-reply The command returns the position of the first bit set to 1 or 0 according to the + * request. + * + * If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is + * returned. + * + * If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns + * the first bit not part of the string on the right. So if the string is tree bytes set to the value 0xff the + * command `BITPOS key 0` will return 24, since up to bit 23 all the bits are 1. + * + * Basically the function consider the right of the string as padded with zeros if you look for clear bits and + * specify no range or the _start_ argument **only**. + * + * However this behavior changes if you are looking for clear bits and specify a range with both __start__ and + * __end__. If no clear bit is found in the specified range, the function returns -1 as the user specified a clear + * range and there are no 0 bits in that range. + */ RedisFuture bitpos(K key, boolean state, long start, long end); RedisFuture bitopAnd(K destination, K... keys); @@ -33,45 +94,186 @@ public interface RedisStringsAsyncConnection { RedisFuture bitopXor(K destination, K... keys); + /** + * Decrement the integer value of a key by one. + * + * @param key the key + * @return RedisFuture integer-reply the value of `key` after the decrement + */ RedisFuture decr(K key); + /** + * Decrement the integer value of a key by the given number. + * + * @param key the key + * @param amount the decrement type: long + * @return RedisFuture integer-reply the value of `key` after the decrement + */ RedisFuture decrby(K key, long amount); + /** + * Get the value of a key. + * + * @param key the key + * @return RedisFuture bulk-string-reply the value of `key`, or `nil` when `key` does not exist. + */ RedisFuture get(K key); + /** + * Returns the bit value at offset in the string value stored at key. + * + * @param key the key + * @param offset the offset type: long + * @return RedisFuture integer-reply the bit value stored at _offset_. + */ RedisFuture getbit(K key, long offset); + /** + * Get a substring of the string stored at a key. + * + * @param key the key + * @param start the start type: long + * @param end the end type: long + * @return RedisFuture bulk-string-reply + */ RedisFuture getrange(K key, long start, long end); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value type: value + * @return RedisFuture bulk-string-reply the old value stored at `key`, or `nil` when `key` did not exist. + */ RedisFuture getset(K key, V value); + /** + * Increment the integer value of a key by one. + * + * @param key the key + * @return RedisFuture integer-reply the value of `key` after the increment + */ RedisFuture incr(K key); + /** + * Increment the integer value of a key by the given amount. + * + * @param key the key + * @param amount the increment type: long + * @return RedisFuture integer-reply the value of `key` after the increment + */ RedisFuture incrby(K key, long amount); + /** + * Increment the float value of a key by the given amount. + * + * @param key the key + * @param amount the increment type: double + * @return RedisFuture bulk-string-reply the value of `key` after the increment. + */ RedisFuture incrbyfloat(K key, double amount); + /** + * Get the values of all the given keys. + * + * @param keys the key + * @return RedisFuture> array-reply list of values at the specified keys. + */ RedisFuture> mget(K... keys); + /** + * Get the values of all the given keys. + * + * @return RedisFuture array-reply list of values at the specified keys. + */ RedisFuture mget(ValueStreamingChannel channel, K... keys); + /** + * Set multiple keys to multiple values. + * + * @param map the null + * @return RedisFuture simple-string-reply always `OK` since `MSET` can't fail. + */ RedisFuture mset(Map map); + /** + * Set multiple keys to multiple values, only if none of the keys exist. + * + * @param map the null + * @return RedisFuture integer-reply specifically: + * + * `1` if the all the keys were set. `0` if no key was set (at least one key already existed). + */ RedisFuture msetnx(Map map); + /** + * Set the string value of a key. + * + * @return RedisFuture simple-string-reply `OK` if `SET` was executed correctly. + */ RedisFuture set(K key, V value); + /** + * Set the string value of a key. + * + * @return RedisFuture simple-string-reply `OK` if `SET` was executed correctly. + */ RedisFuture set(K key, V value, SetArgs setArgs); + /** + * Sets or clears the bit at offset in the string value stored at key. + * + * @param key the key + * @param offset the offset type: long + * @param value the value type: string + * @return RedisFuture integer-reply the original bit value stored at _offset_. + */ RedisFuture setbit(K key, long offset, int value); + /** + * Set the value and expiration of a key. + * + * @param key the key + * @param seconds the seconds type: long + * @param value the value type: value + * @return RedisFuture simple-string-reply + */ RedisFuture setex(K key, long seconds, V value); + /** + * Set the value and expiration in milliseconds of a key. + * + * @param key the key + * @param milliseconds the milliseconds type: long + * @param value the value type: value + */ RedisFuture psetex(K key, long milliseconds, V value); + /** + * Set the value of a key, only if the key does not exist. + * @param key the key + * @param value the value type: value + * @return RedisFuture integer-reply specifically: + + * `1` if the key was set + * `0` if the key was not set + */ RedisFuture setnx(K key, V value); + /** + * Overwrite part of a string at key starting at the specified offset. + * @param key the key + * @param offset the offset type: long + * @param value the value type: value + * @return RedisFuture integer-reply the length of the string after it was modified by the command. + */ RedisFuture setrange(K key, long offset, V value); + /** + * Get the length of the value stored in a key. + * @param key the key + * @return RedisFuture integer-reply the length of the string at `key`, or `0` when `key` does not + exist. + */ RedisFuture strlen(K key); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java index facd148e6a..0fe75dfc66 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java @@ -15,14 +15,73 @@ * @since 17.05.14 21:12 */ public interface RedisStringsConnection { + /** + * Append a value to a key. + * + * @param key the key + * @param value the value type: value + * @return Long integer-reply the length of the string after the append operation. + */ Long append(K key, V value); + /** + * Count set bits in a string. + * + * @return Long integer-reply The number of bits set to 1. + */ Long bitcount(K key); + /** + * Count set bits in a string. + * + * @return Long integer-reply The number of bits set to 1. + */ Long bitcount(K key, long start, long end); + /** + * Find first bit set or clear in a string. + * + * @return Long integer-reply The command returns the position of the first bit set to 1 or 0 according to the request. + * + * If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is + * returned. + * + * If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns + * the first bit not part of the string on the right. So if the string is tree bytes set to the value 0xff the + * command `BITPOS key 0` will return 24, since up to bit 23 all the bits are 1. + * + * Basically the function consider the right of the string as padded with zeros if you look for clear bits and + * specify no range or the _start_ argument **only**. + * + * However this behavior changes if you are looking for clear bits and specify a range with both __start__ and + * __end__. If no clear bit is found in the specified range, the function returns -1 as the user specified a clear + * range and there are no 0 bits in that range. + */ Long bitpos(K key, boolean state); + /** + * Find first bit set or clear in a string. + * + * @param key the key + * @param state the bit type: long + * @param start the start type: long + * @param end the end type: long + * @return Long integer-reply The command returns the position of the first bit set to 1 or 0 according to the request. + * + * If we look for set bits (the bit argument is 1) and the string is empty or composed of just zero bytes, -1 is + * returned. + * + * If we look for clear bits (the bit argument is 0) and the string only contains bit set to 1, the function returns + * the first bit not part of the string on the right. So if the string is tree bytes set to the value 0xff the + * command `BITPOS key 0` will return 24, since up to bit 23 all the bits are 1. + * + * Basically the function consider the right of the string as padded with zeros if you look for clear bits and + * specify no range or the _start_ argument **only**. + * + * However this behavior changes if you are looking for clear bits and specify a range with both __start__ and + * __end__. If no clear bit is found in the specified range, the function returns -1 as the user specified a clear + * range and there are no 0 bits in that range. + */ Long bitpos(K key, boolean state, long start, long end); Long bitopAnd(K destination, K... keys); @@ -33,45 +92,187 @@ public interface RedisStringsConnection { Long bitopXor(K destination, K... keys); + /** + * Decrement the integer value of a key by one. + * + * @param key the key + * @return Long integer-reply the value of `key` after the decrement + */ Long decr(K key); + /** + * Decrement the integer value of a key by the given number. + * + * @param key the key + * @param amount the decrement type: long + * @return Long integer-reply the value of `key` after the decrement + */ Long decrby(K key, long amount); + /** + * Get the value of a key. + * + * @param key the key + * @return V bulk-string-reply the value of `key`, or `nil` when `key` does not exist. + */ V get(K key); + /** + * Returns the bit value at offset in the string value stored at key. + * + * @param key the key + * @param offset the offset type: long + * @return Long integer-reply the bit value stored at _offset_. + */ Long getbit(K key, long offset); + /** + * Get a substring of the string stored at a key. + * + * @param key the key + * @param start the start type: long + * @param end the end type: long + * @return V bulk-string-reply + */ V getrange(K key, long start, long end); + /** + * Set the string value of a key and return its old value. + * + * @param key the key + * @param value the value type: value + * @return V bulk-string-reply the old value stored at `key`, or `nil` when `key` did not exist. + */ V getset(K key, V value); + /** + * Increment the integer value of a key by one. + * + * @param key the key + * @return Long integer-reply the value of `key` after the increment + */ Long incr(K key); + /** + * Increment the integer value of a key by the given amount. + * + * @param key the key + * @param amount the increment type: long + * @return Long integer-reply the value of `key` after the increment + */ Long incrby(K key, long amount); + /** + * Increment the float value of a key by the given amount. + * + * @param key the key + * @param amount the increment type: double + * @return Double bulk-string-reply the value of `key` after the increment. + */ Double incrbyfloat(K key, double amount); + /** + * Get the values of all the given keys. + * + * @param keys the key + * @return List array-reply list of values at the specified keys. + */ List mget(K... keys); + /** + * Get the values of all the given keys. + * + * @return Long array-reply list of values at the specified keys. + */ Long mget(ValueStreamingChannel channel, K... keys); + /** + * Set multiple keys to multiple values. + * + * @param map the null + * @return String simple-string-reply always `OK` since `MSET` can't fail. + */ String mset(Map map); + /** + * Set multiple keys to multiple values, only if none of the keys exist. + * + * @param map the null + * @return Boolean integer-reply specifically: + * + * `1` if the all the keys were set. `0` if no key was set (at least one key already existed). + */ Boolean msetnx(Map map); + /** + * Set the string value of a key. + * + * @return String simple-string-reply `OK` if `SET` was executed correctly. + */ String set(K key, V value); + /** + * Set the string value of a key. + * + * @return V simple-string-reply `OK` if `SET` was executed correctly. + */ V set(K key, V value, SetArgs setArgs); + /** + * Sets or clears the bit at offset in the string value stored at key. + * + * @param key the key + * @param offset the offset type: long + * @param value the value type: string + * @return Long integer-reply the original bit value stored at _offset_. + */ Long setbit(K key, long offset, int value); + /** + * Set the value and expiration of a key. + * + * @param key the key + * @param seconds the seconds type: long + * @param value the value type: value + * @return String simple-string-reply + */ String setex(K key, long seconds, V value); + /** + * Set the value and expiration in milliseconds of a key. + * + * @param key the key + * @param milliseconds the milliseconds type: long + * @param value the value type: value + */ String psetex(K key, long milliseconds, V value); + /** + * Set the value of a key, only if the key does not exist. + * + * @param key the key + * @param value the value type: value + * @return Boolean integer-reply specifically: + * + * `1` if the key was set `0` if the key was not set + */ Boolean setnx(K key, V value); + /** + * Overwrite part of a string at key starting at the specified offset. + * + * @param key the key + * @param offset the offset type: long + * @param value the value type: value + * @return Long integer-reply the length of the string after it was modified by the command. + */ Long setrange(K key, long offset, V value); + /** + * Get the length of the value stored in a key. + * + * @param key the key + * @return Long integer-reply the length of the string at `key`, or `0` when `key` does not exist. + */ Long strlen(K key); } From 7613f72722641465a5de5ddf0b45799087ae490e Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 14:09:09 +0200 Subject: [PATCH 6/8] Documentation --- .../redis/RedisHashesAsyncConnection.java | 4 +- .../redis/RedisHashesConnection.java | 4 +- .../redis/RedisListsAsyncConnection.java | 23 ++++++------ .../redis/RedisListsConnection.java | 14 +++---- .../redis/RedisStringsAsyncConnection.java | 37 ++++++++++--------- .../redis/RedisStringsConnection.java | 12 +++--- 6 files changed, 48 insertions(+), 46 deletions(-) diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java index 14e989a091..01de2cc47e 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesAsyncConnection.java @@ -138,7 +138,7 @@ public interface RedisHashesAsyncConnection { * * @param key the key * @param field the field type: key - * @param value the value type: value + * @param value the value * @return RedisFuture integer-reply specifically: * * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and the @@ -151,7 +151,7 @@ public interface RedisHashesAsyncConnection { * * @param key the key * @param field the field type: key - * @param value the value type: value + * @param value the value * @return RedisFuture integer-reply specifically: * * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and no diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java index 8c2c9a7975..daab42f4d1 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisHashesConnection.java @@ -137,7 +137,7 @@ public interface RedisHashesConnection { * * @param key the key * @param field the field type: key - * @param value the value type: value + * @param value the value * @return Boolean integer-reply specifically: * * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and the @@ -150,7 +150,7 @@ public interface RedisHashesConnection { * * @param key the key * @param field the field type: key - * @param value the value type: value + * @param value the value * @return Boolean integer-reply specifically: * * `1` if `field` is a new field in the hash and `value` was set. `0` if `field` already exists in the hash and no diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java index b5e677b869..724ede36cb 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsAsyncConnection.java @@ -65,7 +65,7 @@ public interface RedisListsAsyncConnection { * @param key the key * @param before the where type: enum * @param pivot the pivot type: value - * @param value the value type: value + * @param value the value * @return RedisFuture integer-reply the length of the list after the insert operation, or `-1` when the value `pivot` * was not found. */ @@ -91,7 +91,7 @@ public interface RedisListsAsyncConnection { * Prepend one or multiple values to a list. * * @param key the key - * @param values the value type: value + * @param values the value * @return RedisFuture integer-reply the length of the list after the push operations. */ RedisFuture lpush(K key, V... values); @@ -100,7 +100,7 @@ public interface RedisListsAsyncConnection { * Prepend a value to a list, only if the list exists. * * @param key the key - * @param value the value type: value + * @param value the value * @return RedisFuture integer-reply the length of the list after the push operation. */ RedisFuture lpushx(K key, V value); @@ -127,7 +127,7 @@ public interface RedisListsAsyncConnection { * * @param key the key * @param count the count type: long - * @param value the value type: value + * @param value the value * @return RedisFuture integer-reply the number of removed elements. */ RedisFuture lrem(K key, long count, V value); @@ -137,7 +137,7 @@ public interface RedisListsAsyncConnection { * * @param key the key * @param index the index type: long - * @param value the value type: value + * @param value the value * @return RedisFuture simple-string-reply */ RedisFuture lset(K key, long index, V value); @@ -173,16 +173,17 @@ public interface RedisListsAsyncConnection { * Append one or multiple values to a list. * * @param key the key - * @param values the value type: value + * @param values the value * @return RedisFuture integer-reply the length of the list after the push operation. */ RedisFuture rpush(K key, V... values); /** - * Append a value to a list, only if the list exists. - * @param key the key - * @param value the value type: value - * @return RedisFuture integer-reply the length of the list after the push operation. - */ + * Append a value to a list, only if the list exists. + * + * @param key the key + * @param value the value + * @return RedisFuture integer-reply the length of the list after the push operation. + */ RedisFuture rpushx(K key, V value); } diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java index d23b9c2c75..e1fc49a7ee 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisListsConnection.java @@ -66,7 +66,7 @@ public interface RedisListsConnection { * @param key the key * @param before the where type: enum * @param pivot the pivot type: value - * @param value the value type: value + * @param value the value * @return Long integer-reply the length of the list after the insert operation, or `-1` when the value `pivot` was not * found. */ @@ -92,7 +92,7 @@ public interface RedisListsConnection { * Prepend one or multiple values to a list. * * @param key the key - * @param values the value type: value + * @param values the value * @return Long integer-reply the length of the list after the push operations. */ Long lpush(K key, V... values); @@ -101,7 +101,7 @@ public interface RedisListsConnection { * Prepend a value to a list, only if the list exists. * * @param key the key - * @param value the value type: value + * @param value the value * @return Long integer-reply the length of the list after the push operation. */ Long lpushx(K key, V value); @@ -128,7 +128,7 @@ public interface RedisListsConnection { * * @param key the key * @param count the count type: long - * @param value the value type: value + * @param value the value * @return Long integer-reply the number of removed elements. */ Long lrem(K key, long count, V value); @@ -138,7 +138,7 @@ public interface RedisListsConnection { * * @param key the key * @param index the index type: long - * @param value the value type: value + * @param value the value * @return String simple-string-reply */ String lset(K key, long index, V value); @@ -174,7 +174,7 @@ public interface RedisListsConnection { * Append one or multiple values to a list. * * @param key the key - * @param values the value type: value + * @param values the value * @return Long integer-reply the length of the list after the push operation. */ Long rpush(K key, V... values); @@ -183,7 +183,7 @@ public interface RedisListsConnection { * Append a value to a list, only if the list exists. * * @param key the key - * @param value the value type: value + * @param value the value * @return Long integer-reply the length of the list after the push operation. */ Long rpushx(K key, V value); diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java index 2286fd5218..fad53b3df2 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsAsyncConnection.java @@ -19,7 +19,7 @@ public interface RedisStringsAsyncConnection { * Append a value to a key. * * @param key the key - * @param value the value type: value + * @param value the value * @return RedisFuture integer-reply the length of the string after the append operation. */ RedisFuture append(K key, V value); @@ -142,7 +142,7 @@ public interface RedisStringsAsyncConnection { * Set the string value of a key and return its old value. * * @param key the key - * @param value the value type: value + * @param value the value * @return RedisFuture bulk-string-reply the old value stored at `key`, or `nil` when `key` did not exist. */ RedisFuture getset(K key, V value); @@ -235,7 +235,7 @@ public interface RedisStringsAsyncConnection { * * @param key the key * @param seconds the seconds type: long - * @param value the value type: value + * @param value the value * @return RedisFuture simple-string-reply */ RedisFuture setex(K key, long seconds, V value); @@ -245,28 +245,29 @@ public interface RedisStringsAsyncConnection { * * @param key the key * @param milliseconds the milliseconds type: long - * @param value the value type: value + * @param value the value */ RedisFuture psetex(K key, long milliseconds, V value); /** - * Set the value of a key, only if the key does not exist. - * @param key the key - * @param value the value type: value - * @return RedisFuture integer-reply specifically: - - * `1` if the key was set - * `0` if the key was not set - */ + * Set the value of a key, only if the key does not exist. + * + * @param key the key + * @param value the value + * @return RedisFuture integer-reply specifically: + * + * `1` if the key was set `0` if the key was not set + */ RedisFuture setnx(K key, V value); /** - * Overwrite part of a string at key starting at the specified offset. - * @param key the key - * @param offset the offset type: long - * @param value the value type: value - * @return RedisFuture integer-reply the length of the string after it was modified by the command. - */ + * Overwrite part of a string at key starting at the specified offset. + * + * @param key the key + * @param offset the offset type: long + * @param value the value + * @return RedisFuture integer-reply the length of the string after it was modified by the command. + */ RedisFuture setrange(K key, long offset, V value); /** diff --git a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java index 0fe75dfc66..638b7641fd 100644 --- a/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java +++ b/lettuce/src/main/java/com/lambdaworks/redis/RedisStringsConnection.java @@ -19,7 +19,7 @@ public interface RedisStringsConnection { * Append a value to a key. * * @param key the key - * @param value the value type: value + * @param value the value * @return Long integer-reply the length of the string after the append operation. */ Long append(K key, V value); @@ -140,7 +140,7 @@ public interface RedisStringsConnection { * Set the string value of a key and return its old value. * * @param key the key - * @param value the value type: value + * @param value the value * @return V bulk-string-reply the old value stored at `key`, or `nil` when `key` did not exist. */ V getset(K key, V value); @@ -233,7 +233,7 @@ public interface RedisStringsConnection { * * @param key the key * @param seconds the seconds type: long - * @param value the value type: value + * @param value the value * @return String simple-string-reply */ String setex(K key, long seconds, V value); @@ -243,7 +243,7 @@ public interface RedisStringsConnection { * * @param key the key * @param milliseconds the milliseconds type: long - * @param value the value type: value + * @param value the value */ String psetex(K key, long milliseconds, V value); @@ -251,7 +251,7 @@ public interface RedisStringsConnection { * Set the value of a key, only if the key does not exist. * * @param key the key - * @param value the value type: value + * @param value the value * @return Boolean integer-reply specifically: * * `1` if the key was set `0` if the key was not set @@ -263,7 +263,7 @@ public interface RedisStringsConnection { * * @param key the key * @param offset the offset type: long - * @param value the value type: value + * @param value the value * @return Long integer-reply the length of the string after it was modified by the command. */ Long setrange(K key, long offset, V value); From d120ccce8fed6675a0a0422faaa189253e0b8337 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 14:24:10 +0200 Subject: [PATCH 7/8] Documentation --- .../java/com/lambdaworks/redis/cluster/package-info.java | 4 ++++ .../java/com/lambdaworks/redis/codec/package-info.java | 4 ++++ .../java/com/lambdaworks/redis/output/package-info.java | 4 ++++ .../main/java/com/lambdaworks/redis/package-info.java | 4 ++++ .../com/lambdaworks/redis/protocol/package-info.java | 4 ++++ .../java/com/lambdaworks/redis/pubsub/package-info.java | 4 ++++ .../java/com/lambdaworks/redis/support/package-info.java | 5 +++++ .../java/com/lambdaworks/redis/PubSubCommandTest.java | 9 +++++---- 8 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/cluster/package-info.java create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/codec/package-info.java create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/output/package-info.java create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/package-info.java create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/protocol/package-info.java create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/pubsub/package-info.java create mode 100644 lettuce/src/main/java/com/lambdaworks/redis/support/package-info.java diff --git a/lettuce/src/main/java/com/lambdaworks/redis/cluster/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/cluster/package-info.java new file mode 100644 index 0000000000..9de8505b30 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/cluster/package-info.java @@ -0,0 +1,4 @@ +/** + * Client for redis clusters {@link com.lambdaworks.redis.cluster.RedisClusterClient} + */ +package com.lambdaworks.redis.cluster; \ No newline at end of file diff --git a/lettuce/src/main/java/com/lambdaworks/redis/codec/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/codec/package-info.java new file mode 100644 index 0000000000..b6f3fa5e50 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/codec/package-info.java @@ -0,0 +1,4 @@ +/** + * Codecs for key/value type conversion. + */ +package com.lambdaworks.redis.codec; \ No newline at end of file diff --git a/lettuce/src/main/java/com/lambdaworks/redis/output/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/output/package-info.java new file mode 100644 index 0000000000..b966f88ce3 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/output/package-info.java @@ -0,0 +1,4 @@ +/** + * Implementation of different output protocols including the Streaming API. + */ +package com.lambdaworks.redis.output; \ No newline at end of file diff --git a/lettuce/src/main/java/com/lambdaworks/redis/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/package-info.java new file mode 100644 index 0000000000..82adf0e005 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/package-info.java @@ -0,0 +1,4 @@ +/** + * The redis client package containing {@link com.lambdaworks.redis.RedisClient} for regular and sentinel operations. + */ +package com.lambdaworks.redis; \ No newline at end of file diff --git a/lettuce/src/main/java/com/lambdaworks/redis/protocol/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/protocol/package-info.java new file mode 100644 index 0000000000..07967b0b47 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/protocol/package-info.java @@ -0,0 +1,4 @@ +/** + * Redis protocol layer abstraction. + */ +package com.lambdaworks.redis.protocol; \ No newline at end of file diff --git a/lettuce/src/main/java/com/lambdaworks/redis/pubsub/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/pubsub/package-info.java new file mode 100644 index 0000000000..d68879e934 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/pubsub/package-info.java @@ -0,0 +1,4 @@ +/** + * Pub/Sub connection classes. + */ +package com.lambdaworks.redis.pubsub; \ No newline at end of file diff --git a/lettuce/src/main/java/com/lambdaworks/redis/support/package-info.java b/lettuce/src/main/java/com/lambdaworks/redis/support/package-info.java new file mode 100644 index 0000000000..1e0c92c386 --- /dev/null +++ b/lettuce/src/main/java/com/lambdaworks/redis/support/package-info.java @@ -0,0 +1,5 @@ +/** + * Supportive classes such as {@link com.lambdaworks.redis.support.CdiProducer} for CDI support, {@link com.lambdaworks.redis.support.RedisClientFactoryBean} for Spring. + */ +package com.lambdaworks.redis.support; + diff --git a/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java b/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java index 113b781cf8..168c38b6b1 100644 --- a/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java +++ b/lettuce/src/test/java/com/lambdaworks/redis/PubSubCommandTest.java @@ -13,12 +13,12 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import com.lambdaworks.redis.pubsub.RedisPubSubConnection; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.lambdaworks.redis.pubsub.RedisPubSubAdapter; +import com.lambdaworks.redis.pubsub.RedisPubSubConnection; import com.lambdaworks.redis.pubsub.RedisPubSubConnectionImpl; import com.lambdaworks.redis.pubsub.RedisPubSubListener; @@ -100,7 +100,7 @@ public void psubscribe() throws Exception { @Test public void pubsubChannels() throws Exception { pubsub.subscribe(channel); - + Thread.sleep(100); List result = redis.pubsubChannels(); assertThat(result, hasItem(channel)); } @@ -108,7 +108,7 @@ public void pubsubChannels() throws Exception { @Test public void pubsubChannelsWithArg() throws Exception { pubsub.subscribe(channel); - + Thread.sleep(100); List result = redis.pubsubChannels(pattern); assertThat(result, hasItem(channel)); } @@ -117,6 +117,7 @@ public void pubsubChannelsWithArg() throws Exception { public void pubsubNumsub() throws Exception { pubsub.subscribe(channel); + Thread.sleep(100); Map result = redis.pubsubNumsub(channel); assertEquals(1, result.size()); @@ -127,7 +128,7 @@ public void pubsubNumsub() throws Exception { public void pubsubNumpat() throws Exception { pubsub.psubscribe(pattern); - + Thread.sleep(100); Long result = redis.pubsubNumpat(); assertEquals(1L, result.longValue()); } From 34823a6dbf4c2b3a3c092a669868620f33e55f19 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 18 Jun 2014 14:30:00 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6f15411e0e..cfd01e935e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ lettuce - A scalable Java Redis client ====================================== +[![Build Status](https://snap-ci.com/mp911de/lettuce/branch/master/build_image)](https://snap-ci.com/mp911de/lettuce/branch/master) + Lettuce is a scalable thread-safe Redis client providing both synchronous and asynchronous connections. Multiple threads may share one connection provided they avoid blocking and transactional operations such as BLPOP, and MULTI/EXEC.