From 5c4601584aa021b05e4f0c8c9cd8b013b5e1b847 Mon Sep 17 00:00:00 2001 From: SanHalacogluImproving <144171266+SanHalacogluImproving@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:19:35 -0800 Subject: [PATCH] Java: Add examples to missing commands and minor fixes Generic Commands. (#125) (#1070) * Java: Add examples to missing commands and minor fixes. (#125) * Minor documentation changes. * Minor documentation changes. --- .../api/commands/GenericBaseCommands.java | 91 ++++++++++--------- .../api/commands/GenericClusterCommands.java | 35 +++++-- .../glide/api/commands/GenericCommands.java | 12 +++ 3 files changed, 87 insertions(+), 51 deletions(-) diff --git a/java/client/src/main/java/glide/api/commands/GenericBaseCommands.java b/java/client/src/main/java/glide/api/commands/GenericBaseCommands.java index e7a47bf279..d8c29319aa 100644 --- a/java/client/src/main/java/glide/api/commands/GenericBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/GenericBaseCommands.java @@ -18,6 +18,11 @@ public interface GenericBaseCommands { * @see redis.io for details. * @param keys The keys we wanted to remove. * @return The number of keys that were removed. + * @example + *
{@code + * Long num = client.del(new String[] {"key1", "key2"}).get(); + * assert num == 2l; + * }*/ CompletableFuture
keys
*
multiple times, it will be counted multiple times.
* @example
- *
- *
- * long result = client.exists(new String[] {"my_key", "invalid_key"}).get();
+ *
+ * }
*/
CompletableFuture{@code
+ * Long result = client.exists(new String[] {"my_key", "invalid_key"}).get();
* assert result == 1L;
- *
keys
that were unlinked.
* @example
- *
- * long result = client.unlink("my_key").get();
+ *
*/
CompletableFuture{@code
+ * Long result = client.unlink("my_key").get();
* assert result == 1L;
- *
+ * }true
if the timeout was set. false
if the timeout was not
* set. e.g. key
doesn't exist.
* @example
- *
- * Boolean isSet = client.expire("my_key", 60).get()
- * assert isSet //Indicates that a timeout of 60 seconds has been set for "my_key."
- *
+ * {@code
+ * Boolean isSet = client.expire("my_key", 60).get();
+ * assert isSet; //Indicates that a timeout of 60 seconds has been set for "my_key."
+ * }
*/
CompletableFuturekey
doesn't exist, or operation skipped due to the provided
* arguments.
* @example
- *
- * Boolean isSet = client.expire("my_key", 60, ExpireOptions.HAS_NO_EXPIRY).get()
- * assert isSet //Indicates that a timeout of 60 seconds has been set for "my_key."
- *
+ * {@code
+ * Boolean isSet = client.expire("my_key", 60, ExpireOptions.HAS_NO_EXPIRY).get();
+ * assert isSet; //Indicates that a timeout of 60 seconds has been set for "my_key."
+ * }
*/
CompletableFuturetrue
if the timeout was set. false
if the timeout was not
* set. e.g. key
doesn't exist.
* @example
- *
- * Boolean isSet = client.expireAt("my_key", Instant.now().getEpochSecond() + 10).get()
- * assert isSet
- *
+ * {@code
+ * Boolean isSet = client.expireAt("my_key", Instant.now().getEpochSecond() + 10).get();
+ * assert isSet;
+ * }
*/
CompletableFuturekey
doesn't exist, or operation skipped due to the provided
* arguments.
* @example
- *
- * Boolean isSet = client.expireAt("my_key", Instant.now().getEpochSecond() + 10, ExpireOptions.HasNoExpiry).get()
- * assert isSet
- *
+ * {@code
+ * Boolean isSet = client.expireAt("my_key", Instant.now().getEpochSecond() + 10, ExpireOptions.HasNoExpiry).get();
+ * assert isSet;
+ * }
*/
CompletableFuturetrue
if the timeout was set. false
if the timeout was not
* set. e.g. key
doesn't exist.
* @example
- *
- * Boolean isSet = client.pexpire("my_key", 60000).get()
- * assert isSet
- *
+ * {@code
+ * Boolean isSet = client.pexpire("my_key", 60000).get();
+ * assert isSet;
+ * }
*/
CompletableFuturekey
doesn't exist, or operation skipped due to the provided
* arguments.
* @example
- *
- * Boolean isSet = client.pexpire("my_key", 60000, ExpireOptions.HasNoExpiry).get()
- * assert isSet
- *
+ * {@code
+ * Boolean isSet = client.pexpire("my_key", 60000, ExpireOptions.HasNoExpiry).get();
+ * assert isSet;
+ * }
*/
CompletableFuturetrue
if the timeout was set. false
if the timeout was not
* set. e.g. key
doesn't exist.
* @example
- *
- * Boolean isSet = client.pexpireAt("my_key", Instant.now().toEpochMilli() + 10).get()
- * assert isSet
- *
+ * {@code
+ * Boolean isSet = client.pexpireAt("my_key", Instant.now().toEpochMilli() + 10).get();
+ * assert isSet;
+ * }
*/
CompletableFuturekey
doesn't exist, or operation skipped due to the provided
* arguments.
* @example
- *
- * Boolean isSet = client.pexpireAt("my_key", Instant.now().toEpochMilli() + 10, ExpireOptions.HasNoExpiry).get()
- * assert isSet
- *
+ * {@code
+ * Boolean isSet = client.pexpireAt("my_key", Instant.now().toEpochMilli() + 10, ExpireOptions.HasNoExpiry).get();
+ * assert isSet;
+ * }
*/
CompletableFuture-2
if key
does not exist, or -1
* if key
exists but has no associated expire.
* @example
- *
+ *
*/
CompletableFuture{@code
* Long timeRemaining = client.ttl("my_key").get()
* assert timeRemaining == 3600L //Indicates that "my_key" has a remaining time to live of 3600 seconds.
- * Long timeRemaining = client.ttl("nonexistent_key").get()
- * assert timeRemaining == -2L //Returns -2 for a non-existing key.
- *
+ *
+ * Long timeRemaining = client.ttl("nonexistent_key").get();
+ * assert timeRemaining == -2L; //Returns -2 for a non-existing key.
+ * }
- * Object result = client.customCommand(new String[]{ "CLIENT", "LIST", "TYPE", "PUBSUB" }).get();
- *
* @param args Arguments for the custom command including the command name.
* @return Response from Redis containing an Object
.
+ * @example
+ * {@code
+ * ClusterValue
*/
CompletableFuture
- * Object result = client.customCommand(new String[]{ "CLIENT", "LIST", "TYPE", "PUBSUB" }, RANDOM).get();
- *
* @param args Arguments for the custom command including the command name
* @param route Routing configuration for the command
* @return Response from Redis containing an Object
.
+ * @example
+ * {@code
+ * ClusterValue
*/
CompletableFutureWATCH
command, exec
will
* return null
.
*
+ *
+ * @example
+ * {@code
+ * ClusterTransaction transaction = new ClusterTransaction().customCommand(new String[] {"info"});
+ * Object[] result = clusterClient.exec(transaction).get();
+ * assert ((String) result[0]).contains("# Stats");
+ * }
*/
CompletableFuture