Skip to content

Commit

Permalink
Java/Node: Update docs for xadd and xtrim (valkey-io#1246)
Browse files Browse the repository at this point in the history
* Java: Add XADD command (Stream commands) (#155)

* Add Stream XADD command to Java

Signed-off-by: Andrew Carbonetto <[email protected]>

---------

Signed-off-by: Andrew Carbonetto <[email protected]>

* Java: Add Zpopmax command. (Sorted Set Commands) (valkey-io#1164)

* Java: Add Zpopmax command. (Sorted Set Commands) (#149)

* Minor documentation update.

* Minor test update.

* Spotless

Signed-off-by: Andrew Carbonetto <[email protected]>

* Minor documentation update.

* Rebase + Spotless

---------

Signed-off-by: Andrew Carbonetto <[email protected]>
Co-authored-by: Andrew Carbonetto <[email protected]>

* Spotless

Signed-off-by: Andrew Carbonetto <[email protected]>

* Clean up merge

Signed-off-by: Andrew Carbonetto <[email protected]>

* Move xadd command

Signed-off-by: Andrew Carbonetto <[email protected]>

* Spotless

Signed-off-by: Andrew Carbonetto <[email protected]>

* PR comments.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Update xtrim documentation

Signed-off-by: Andrew Carbonetto <[email protected]>

* Spotless

Signed-off-by: Andrew Carbonetto <[email protected]>

---------

Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: SanHalacogluImproving <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
3 people authored and alex-arzola-imp committed Apr 12, 2024
1 parent 100deb7 commit 1fd9f43
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -14,7 +15,8 @@
public interface StreamBaseCommands {

/**
* Adds an entry to the specified stream.
* Adds an entry to the specified stream stored at <code>key</code>.<br>
* If the <code>key</code> doesn't exist, the stream is created.
*
* @see <a href="https://redis.io/commands/xadd/">redis.io</a> for details.
* @param key The key of the stream.
Expand All @@ -29,14 +31,16 @@ public interface StreamBaseCommands {
CompletableFuture<String> xadd(String key, Map<String, String> values);

/**
* Adds an entry to the specified stream.
* Adds an entry to the specified stream stored at <code>key</code>.<br>
* If the <code>key</code> doesn't exist, the stream is created.
*
* @see <a href="https://redis.io/commands/xadd/">redis.io</a> 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 <code>null</code> if {@link StreamAddOptions#makeStream}
* is set to <code>false</code> and no stream with the matching <code>key</code> exists.
* @return The id of the added entry, or <code>null</code> if {@link
* StreamAddOptionsBuilder#makeStream(Boolean)} is set to <code>false</code> and no stream
* with the matching <code>key</code> exists.
* @example
* <pre>{@code
* // Option to use the existing stream, or return null if the stream doesn't already exist at "key"
Expand Down
11 changes: 7 additions & 4 deletions java/client/src/main/java/glide/api/models/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <code>key</code>.<br>
* If the <code>key</code> doesn't exist, the stream is created.
*
* @see <a href="https://redis.io/commands/xadd/">redis.io</a> for details.
* @param key The key of the stream.
Expand All @@ -1546,15 +1548,16 @@ public T xadd(@NonNull String key, @NonNull Map<String, String> values) {
}

/**
* Adds an entry to the specified stream.
* Adds an entry to the specified stream stored at <code>key</code>.<br>
* If the <code>key</code> doesn't exist, the stream is created.
*
* @see <a href="https://redis.io/commands/xadd/">redis.io</a> 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 <code>null</code> if {@link
* StreamAddOptions#makeStream} is set to <code>false</code> and no stream with the matching
* <code>key</code> exists.
* StreamAddOptionsBuilder#makeStream(Boolean)} is set to <code>false</code> and no stream
* with the matching <code>key</code> exists.
*/
public T xadd(
@NonNull String key, @NonNull Map<String, String> values, @NonNull StreamAddOptions options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://redis.io/commands/xadd/">redis.io</a>
*/
Expand Down
6 changes: 3 additions & 3 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<number> {
return this.createWritePromise(createXtrim(key, options));
Expand Down
6 changes: 3 additions & 3 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
}

/**
* 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.
Expand All @@ -1190,12 +1190,12 @@ export class BaseTransaction<T extends BaseTransaction<T>> {
}

/**
* 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));
Expand Down

0 comments on commit 1fd9f43

Please sign in to comment.