From dd8724b7084be64b4c3a4e91ac0d5fc63321e59e Mon Sep 17 00:00:00 2001 From: Guian Gumpac Date: Tue, 18 Jun 2024 22:37:54 +0000 Subject: [PATCH] Separated unwatch to have different docs for standalone (#1597) Separated unwatch to have different docs for standalone (#372) * Separated unwatch to have different docs for standalone * Added line break --- .../src/main/java/glide/api/BaseClient.java | 6 ----- .../src/main/java/glide/api/RedisClient.java | 10 +++++++- .../java/glide/api/RedisClusterClient.java | 5 ++++ .../commands/TransactionsBaseCommands.java | 14 ----------- .../commands/TransactionsClusterCommands.java | 4 +-- .../api/commands/TransactionsCommands.java | 25 +++++++++++++++++++ 6 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 java/client/src/main/java/glide/api/commands/TransactionsCommands.java diff --git a/java/client/src/main/java/glide/api/BaseClient.java b/java/client/src/main/java/glide/api/BaseClient.java index 26cd155f68..2f663bc5cc 100644 --- a/java/client/src/main/java/glide/api/BaseClient.java +++ b/java/client/src/main/java/glide/api/BaseClient.java @@ -118,7 +118,6 @@ import static redis_request.RedisRequestOuterClass.RequestType.TTL; import static redis_request.RedisRequestOuterClass.RequestType.Touch; import static redis_request.RedisRequestOuterClass.RequestType.Type; -import static redis_request.RedisRequestOuterClass.RequestType.UnWatch; import static redis_request.RedisRequestOuterClass.RequestType.Unlink; import static redis_request.RedisRequestOuterClass.RequestType.Watch; import static redis_request.RedisRequestOuterClass.RequestType.XAdd; @@ -1900,9 +1899,4 @@ public CompletableFuture lcsLen(@NonNull String key1, @NonNull String key2 public CompletableFuture watch(@NonNull String[] keys) { return commandManager.submitNewCommand(Watch, keys, this::handleStringResponse); } - - @Override - public CompletableFuture unwatch() { - return commandManager.submitNewCommand(UnWatch, new String[0], this::handleStringResponse); - } } diff --git a/java/client/src/main/java/glide/api/RedisClient.java b/java/client/src/main/java/glide/api/RedisClient.java index 9750b8a19d..db36fd4bed 100644 --- a/java/client/src/main/java/glide/api/RedisClient.java +++ b/java/client/src/main/java/glide/api/RedisClient.java @@ -31,11 +31,13 @@ import static redis_request.RedisRequestOuterClass.RequestType.Ping; import static redis_request.RedisRequestOuterClass.RequestType.Select; import static redis_request.RedisRequestOuterClass.RequestType.Time; +import static redis_request.RedisRequestOuterClass.RequestType.UnWatch; import glide.api.commands.ConnectionManagementCommands; import glide.api.commands.GenericCommands; import glide.api.commands.ScriptingAndFunctionsCommands; import glide.api.commands.ServerManagementCommands; +import glide.api.commands.TransactionsCommands; import glide.api.models.Transaction; import glide.api.models.commands.FlushMode; import glide.api.models.commands.InfoOptions; @@ -56,7 +58,8 @@ public class RedisClient extends BaseClient implements GenericCommands, ServerManagementCommands, ConnectionManagementCommands, - ScriptingAndFunctionsCommands { + ScriptingAndFunctionsCommands, + TransactionsCommands { protected RedisClient(ConnectionManager connectionManager, CommandManager commandManager) { super(connectionManager, commandManager); @@ -297,4 +300,9 @@ public CompletableFuture>> functionStats() { new String[0], response -> handleFunctionStatsResponse(handleMapResponse(response))); } + + @Override + public CompletableFuture unwatch() { + return commandManager.submitNewCommand(UnWatch, new String[0], this::handleStringResponse); + } } diff --git a/java/client/src/main/java/glide/api/RedisClusterClient.java b/java/client/src/main/java/glide/api/RedisClusterClient.java index 86fc485f40..97ddb65ddc 100644 --- a/java/client/src/main/java/glide/api/RedisClusterClient.java +++ b/java/client/src/main/java/glide/api/RedisClusterClient.java @@ -660,4 +660,9 @@ public CompletableFuture unwatch(@NonNull Route route) { return commandManager.submitNewCommand( UnWatch, new String[0], route, this::handleStringResponse); } + + @Override + public CompletableFuture unwatch() { + return commandManager.submitNewCommand(UnWatch, new String[0], this::handleStringResponse); + } } diff --git a/java/client/src/main/java/glide/api/commands/TransactionsBaseCommands.java b/java/client/src/main/java/glide/api/commands/TransactionsBaseCommands.java index 99585da025..b7d5c9b504 100644 --- a/java/client/src/main/java/glide/api/commands/TransactionsBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/TransactionsBaseCommands.java @@ -34,18 +34,4 @@ public interface TransactionsBaseCommands { * } */ CompletableFuture watch(String[] keys); - - /** - * Flushes all the previously watched keys for a transaction. Executing a transaction will - * automatically flush all previously watched keys. - * - * @see redis.io for details. - * @return OK. - * @example - *
{@code
-     * assert client.watch(new String[] {"sampleKey"}).get().equals("OK");
-     * assert client.unwatch().get().equals("OK"); // Flushes "sampleKey" from watched keys.
-     * }
- */ - CompletableFuture unwatch(); } diff --git a/java/client/src/main/java/glide/api/commands/TransactionsClusterCommands.java b/java/client/src/main/java/glide/api/commands/TransactionsClusterCommands.java index 02edc5e7ad..ff381904e7 100644 --- a/java/client/src/main/java/glide/api/commands/TransactionsClusterCommands.java +++ b/java/client/src/main/java/glide/api/commands/TransactionsClusterCommands.java @@ -12,8 +12,8 @@ public interface TransactionsClusterCommands { /** * Flushes all the previously watched keys for a transaction. Executing a transaction will - * automatically flush all previously watched keys. The command will be routed to all primary - * nodes. + * automatically flush all previously watched keys.
+ * The command will be routed to all primary nodes. * * @see redis.io for details. * @return OK. diff --git a/java/client/src/main/java/glide/api/commands/TransactionsCommands.java b/java/client/src/main/java/glide/api/commands/TransactionsCommands.java new file mode 100644 index 0000000000..1d1cefbfa6 --- /dev/null +++ b/java/client/src/main/java/glide/api/commands/TransactionsCommands.java @@ -0,0 +1,25 @@ +/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ +package glide.api.commands; + +import java.util.concurrent.CompletableFuture; + +/** + * Supports commands for the "Transactions Commands" group for standalone clients. + * + * @see Transactions Commands + */ +public interface TransactionsCommands { + /** + * Flushes all the previously watched keys for a transaction. Executing a transaction will + * automatically flush all previously watched keys. + * + * @see redis.io for details. + * @return OK. + * @example + *
{@code
+     * assert client.watch(new String[] {"sampleKey"}).get().equals("OK");
+     * assert client.unwatch().get().equals("OK"); // Flushes "sampleKey" from watched keys.
+     * }
+ */ + CompletableFuture unwatch(); +}