From 0a430cf35db910745fde4bacf08100ee6ae7b56a Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Wed, 10 Apr 2024 13:30:02 -0700 Subject: [PATCH] Java/Node: Update docs for `xadd` and `xtrim` (#1246) * Java: Add XADD command (Stream commands) (#155) * Add Stream XADD command to Java Signed-off-by: Andrew Carbonetto --------- Signed-off-by: Andrew Carbonetto * Java: Add Zpopmax command. (Sorted Set Commands) (#1164) * Java: Add Zpopmax command. (Sorted Set Commands) (#149) * Minor documentation update. * Minor test update. * Spotless Signed-off-by: Andrew Carbonetto * Minor documentation update. * Rebase + Spotless --------- Signed-off-by: Andrew Carbonetto Co-authored-by: Andrew Carbonetto * Spotless Signed-off-by: Andrew Carbonetto * Clean up merge Signed-off-by: Andrew Carbonetto * Move xadd command Signed-off-by: Andrew Carbonetto * Spotless Signed-off-by: Andrew Carbonetto * PR comments. Signed-off-by: Yury-Fridlyand * Update xtrim documentation Signed-off-by: Andrew Carbonetto * Spotless Signed-off-by: Andrew Carbonetto --------- Signed-off-by: Andrew Carbonetto Signed-off-by: Yury-Fridlyand Co-authored-by: SanHalacogluImproving <144171266+SanHalacogluImproving@users.noreply.github.com> Co-authored-by: Yury-Fridlyand --- .../java/glide/api/commands/StreamBaseCommands.java | 12 ++++++++---- .../main/java/glide/api/models/BaseTransaction.java | 11 +++++++---- .../glide/api/models/commands/StreamAddOptions.java | 3 ++- node/src/BaseClient.ts | 6 +++--- node/src/Transaction.ts | 6 +++--- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java b/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java index d3bb55fe91..2fa1ff4daf 100644 --- a/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java @@ -2,6 +2,7 @@ package glide.api.commands; import glide.api.models.commands.StreamAddOptions; +import glide.api.models.commands.StreamAddOptions.StreamAddOptionsBuilder; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -14,7 +15,8 @@ public interface StreamBaseCommands { /** - * Adds an entry to the specified stream. + * Adds an entry to the specified stream stored at key.
+ * If the key doesn't exist, the stream is created. * * @see redis.io for details. * @param key The key of the stream. @@ -29,14 +31,16 @@ public interface StreamBaseCommands { CompletableFuture xadd(String key, Map values); /** - * Adds an entry to the specified stream. + * Adds an entry to the specified stream stored at key.
+ * If the key doesn't exist, the stream is created. * * @see redis.io for details. * @param key The key of the stream. * @param values Field-value pairs to be added to the entry. * @param options Stream add options. - * @return The id of the added entry, or null if {@link StreamAddOptions#makeStream} - * is set to false and no stream with the matching key exists. + * @return The id of the added entry, or null if {@link + * StreamAddOptionsBuilder#makeStream(Boolean)} is set to false and no stream + * with the matching key exists. * @example *
{@code
      * // Option to use the existing stream, or return null if the stream doesn't already exist at "key"
diff --git a/java/client/src/main/java/glide/api/models/BaseTransaction.java b/java/client/src/main/java/glide/api/models/BaseTransaction.java
index a467e5bdf6..43d083c9fb 100644
--- a/java/client/src/main/java/glide/api/models/BaseTransaction.java
+++ b/java/client/src/main/java/glide/api/models/BaseTransaction.java
@@ -93,6 +93,7 @@
 import glide.api.models.commands.SetOptions.ConditionalSet;
 import glide.api.models.commands.SetOptions.SetOptionsBuilder;
 import glide.api.models.commands.StreamAddOptions;
+import glide.api.models.commands.StreamAddOptions.StreamAddOptionsBuilder;
 import glide.api.models.commands.ZaddOptions;
 import java.util.Map;
 import lombok.Getter;
@@ -1533,7 +1534,8 @@ public T zmscore(@NonNull String key, @NonNull String[] members) {
     }
 
     /**
-     * Adds an entry to the specified stream.
+     * Adds an entry to the specified stream stored at key.
+ * If the key doesn't exist, the stream is created. * * @see redis.io for details. * @param key The key of the stream. @@ -1546,15 +1548,16 @@ public T xadd(@NonNull String key, @NonNull Map values) { } /** - * Adds an entry to the specified stream. + * Adds an entry to the specified stream stored at key.
+ * If the key doesn't exist, the stream is created. * * @see redis.io for details. * @param key The key of the stream. * @param values Field-value pairs to be added to the entry. * @param options Stream add options. * @return Command Response - The id of the added entry, or null if {@link - * StreamAddOptions#makeStream} is set to false and no stream with the matching - * key exists. + * StreamAddOptionsBuilder#makeStream(Boolean)} is set to false and no stream + * with the matching key exists. */ public T xadd( @NonNull String key, @NonNull Map values, @NonNull StreamAddOptions options) { diff --git a/java/client/src/main/java/glide/api/models/commands/StreamAddOptions.java b/java/client/src/main/java/glide/api/models/commands/StreamAddOptions.java index 1c3e1c336e..34509523ed 100644 --- a/java/client/src/main/java/glide/api/models/commands/StreamAddOptions.java +++ b/java/client/src/main/java/glide/api/models/commands/StreamAddOptions.java @@ -4,11 +4,12 @@ import glide.api.commands.StreamBaseCommands; import java.util.ArrayList; import java.util.List; +import java.util.Map; import lombok.Builder; import lombok.NonNull; /** - * Optional arguments to {@link StreamBaseCommands#xadd} + * Optional arguments to {@link StreamBaseCommands#xadd(String, Map, StreamAddOptions)} * * @see redis.io */ diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 220f8c3e57..c2a36c8b96 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -2056,7 +2056,7 @@ export class BaseClient { } /** - * Adds an entry to the specified stream. + * Adds an entry to the specified stream stored at `key`. If the `key` doesn't exist, the stream is created. * See https://redis.io/commands/xadd/ for more details. * * @param key - The key of the stream. @@ -2072,12 +2072,12 @@ export class BaseClient { } /** - * Trims the stream by evicting older entries. + * Trims the stream stored at `key` by evicting older entries. * See https://redis.io/commands/xtrim/ for more details. * * @param key - the key of the stream * @param options - options detailing how to trim the stream. - * @returns The number of entries deleted from the stream. + * @returns The number of entries deleted from the stream. If `key` doesn't exist, 0 is returned. */ public xtrim(key: string, options: StreamTrimOptions): Promise { return this.createWritePromise(createXtrim(key, options)); diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index b2fbdef317..6b118f57d6 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -1174,7 +1174,7 @@ export class BaseTransaction> { } /** - * Adds an entry to the specified stream. + * Adds an entry to the specified stream stored at `key`. If the `key` doesn't exist, the stream is created. * See https://redis.io/commands/xadd/ for more details. * * @param key - The key of the stream. @@ -1190,12 +1190,12 @@ export class BaseTransaction> { } /** - * Trims the stream by evicting older entries. + * Trims the stream stored at `key` by evicting older entries. * See https://redis.io/commands/xtrim/ for more details. * * @param key - the key of the stream * @param options - options detailing how to trim the stream. - * @returns The number of entries deleted from the stream. + * @returns The number of entries deleted from the stream. If `key` doesn't exist, 0 is returned. */ public xtrim(key: string, options: StreamTrimOptions): T { return this.addAndReturn(createXtrim(key, options));