diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c724e6c52..5cc1f7c86a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * Go: Add `ZPopMin` and `ZPopMax` ([#2850](https://github.com/valkey-io/valkey-glide/pull/2850)) * Java: Add binary version of `ZRANK WITHSCORE` ([#2896](https://github.com/valkey-io/valkey-glide/pull/2896)) * Go: Add `ZCARD` ([#2838](https://github.com/valkey-io/valkey-glide/pull/2838)) +* Java, Node, Python: Update documentation for CONFIG SET and CONFIG GET ([#2919](https://github.com/valkey-io/valkey-glide/pull/2919)) * Go: Add `BZPopMin` ([#2849](https://github.com/valkey-io/valkey-glide/pull/2849)) #### Breaking Changes diff --git a/java/client/src/main/java/glide/api/commands/ServerManagementClusterCommands.java b/java/client/src/main/java/glide/api/commands/ServerManagementClusterCommands.java index 92293de532..af6a1d3a24 100644 --- a/java/client/src/main/java/glide/api/commands/ServerManagementClusterCommands.java +++ b/java/client/src/main/java/glide/api/commands/ServerManagementClusterCommands.java @@ -170,6 +170,7 @@ public interface ServerManagementClusterCommands { /** * Get the values of configuration parameters.
+ * Starting from server version 7, command supports multiple parameters.
* The command will be sent to a random node. * * @see valkey.io for details. @@ -186,7 +187,8 @@ public interface ServerManagementClusterCommands { CompletableFuture> configGet(String[] parameters); /** - * Get the values of configuration parameters. + * Get the values of configuration parameters.
+ * Starting from server version 7, command supports multiple parameters. * * @see valkey.io for details. * @param parameters An array of configuration parameter names to retrieve values @@ -210,6 +212,7 @@ public interface ServerManagementClusterCommands { /** * Sets configuration parameters to the specified values.
+ * Starting from server version 7, command supports multiple parameters.
* The command will be sent to all nodes. * * @see valkey.io for details. @@ -226,7 +229,8 @@ public interface ServerManagementClusterCommands { CompletableFuture configSet(Map parameters); /** - * Sets configuration parameters to the specified values. + * Sets configuration parameters to the specified values.
+ * Starting from server version 7, command supports multiple parameters. * * @see valkey.io for details. * @param parameters A map consisting of configuration parameters and their diff --git a/java/client/src/main/java/glide/api/commands/ServerManagementCommands.java b/java/client/src/main/java/glide/api/commands/ServerManagementCommands.java index 3617ce3af0..9c7104d99b 100644 --- a/java/client/src/main/java/glide/api/commands/ServerManagementCommands.java +++ b/java/client/src/main/java/glide/api/commands/ServerManagementCommands.java @@ -89,7 +89,8 @@ public interface ServerManagementCommands { CompletableFuture configResetStat(); /** - * Get the values of configuration parameters. + * Get the values of configuration parameters.
+ * Starting from server version 7, command supports multiple parameters. * * @see valkey.io for details. * @param parameters An array of configuration parameter names to retrieve values @@ -105,7 +106,8 @@ public interface ServerManagementCommands { CompletableFuture> configGet(String[] parameters); /** - * Sets configuration parameters to the specified values. + * Sets configuration parameters to the specified values.
+ * Starting from server version 7, command supports multiple parameters. * * @see valkey.io for details. * @param parameters A map consisting of configuration parameters and their 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 bfdd81efc0..9ef52710e0 100644 --- a/java/client/src/main/java/glide/api/models/BaseTransaction.java +++ b/java/client/src/main/java/glide/api/models/BaseTransaction.java @@ -1648,7 +1648,8 @@ public T sunionstore(@NonNull ArgType destination, @NonNull ArgType[] } /** - * Reads the configuration parameters of the running server. + * Reads the configuration parameters of the running server.
+ * Starting from server version 7, command supports multiple parameters. * * @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type * will throw {@link IllegalArgumentException}. @@ -1665,7 +1666,8 @@ public T configGet(@NonNull ArgType[] parameters) { } /** - * Sets configuration parameters to the specified values. + * Sets configuration parameters to the specified values.
+ * Starting from server version 7, command supports multiple parameters. * * @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type * will throw {@link IllegalArgumentException}. diff --git a/java/integTest/src/test/java/glide/TransactionTestUtilities.java b/java/integTest/src/test/java/glide/TransactionTestUtilities.java index 46545f786a..c155ae908a 100644 --- a/java/integTest/src/test/java/glide/TransactionTestUtilities.java +++ b/java/integTest/src/test/java/glide/TransactionTestUtilities.java @@ -813,17 +813,40 @@ private static Object[] serverManagementCommands(BaseTransaction transaction) .flushdb(ASYNC) .dbsize(); - return new Object[] { - OK, // configSet(Map.of("timeout", "1000")) - Map.of("timeout", "1000"), // configGet(new String[] {"timeout"}) - OK, // configResetStat() - "Redis ver. " + SERVER_VERSION + '\n', // lolwut(1) - OK, // flushall() - OK, // flushall(ASYNC) - OK, // flushdb() - OK, // flushdb(ASYNC) - 0L, // dbsize() - }; + if (SERVER_VERSION.isGreaterThanOrEqualTo("7.0.0")) { + transaction + .configSet(Map.of("timeout", "2000", "rdb-save-incremental-fsync", "no")) + .configGet(new String[] {"timeout", "rdb-save-incremental-fsync"}); + } + + var expectedResults = + new Object[] { + OK, // configSet(Map.of("timeout", "1000")) + Map.of("timeout", "1000"), // configGet(new String[] {"timeout"}) + OK, // configResetStat() + "Redis ver. " + SERVER_VERSION + '\n', // lolwut(1) + OK, // flushall() + OK, // flushall(ASYNC) + OK, // flushdb() + OK, // flushdb(ASYNC) + 0L, // dbsize() + }; + + if (SERVER_VERSION.isGreaterThanOrEqualTo("7.0.0")) { + expectedResults = + concatenateArrays( + expectedResults, + new Object[] { + OK, // configSet(Map.of("timeout", "2000", "rdb-save-incremental-fsync", "no")) + Map.of( + "timeout", + "2000", + "rdb-save-incremental-fsync", + "no"), // configGet(new String[] {"timeout", "rdb-save-incremental-fsync"}) + }); + } + + return expectedResults; } private static Object[] connectionManagementCommands(BaseTransaction transaction) { diff --git a/node/src/GlideClient.ts b/node/src/GlideClient.ts index fc9301bd75..9270e7f814 100644 --- a/node/src/GlideClient.ts +++ b/node/src/GlideClient.ts @@ -490,6 +490,7 @@ export class GlideClient extends BaseClient { /** * Reads the configuration parameters of the running server. + * Starting from server version 7, command supports multiple parameters. * * @see {@link https://valkey.io/commands/config-get/|valkey.io} for details. * @@ -517,6 +518,7 @@ export class GlideClient extends BaseClient { /** * Sets configuration parameters to the specified values. + * Starting from server version 7, command supports multiple parameters. * * @see {@link https://valkey.io/commands/config-set/|valkey.io} for details. * @param parameters - A map consisting of configuration parameters and their respective values to set. diff --git a/node/src/GlideClusterClient.ts b/node/src/GlideClusterClient.ts index c12264f078..d21914ec46 100644 --- a/node/src/GlideClusterClient.ts +++ b/node/src/GlideClusterClient.ts @@ -943,6 +943,7 @@ export class GlideClusterClient extends BaseClient { /** * Reads the configuration parameters of the running server. + * Starting from server version 7, command supports multiple parameters. * * The command will be routed to a random node, unless `route` is provided. * @@ -981,6 +982,7 @@ export class GlideClusterClient extends BaseClient { /** * Sets configuration parameters to the specified values. + * Starting from server version 7, command supports multiple parameters. * * The command will be routed to all nodes, unless `route` is provided. * diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index bdccbe151f..4d28d6f82c 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -744,6 +744,7 @@ export class BaseTransaction> { /** * Reads the configuration parameters of the running server. + * Starting from server version 7, command supports multiple parameters. * * @see {@link https://valkey.io/commands/config-get/|valkey.io} for details. * @@ -758,6 +759,7 @@ export class BaseTransaction> { /** * Sets configuration parameters to the specified values. + * Starting from server version 7, command supports multiple parameters. * * @see {@link https://valkey.io/commands/config-set/|valkey.io} for details. * diff --git a/node/tests/GlideClusterClient.test.ts b/node/tests/GlideClusterClient.test.ts index f2553131f1..2d5b86f52e 100644 --- a/node/tests/GlideClusterClient.test.ts +++ b/node/tests/GlideClusterClient.test.ts @@ -34,6 +34,7 @@ import { SlotKeyTypes, SortOrder, convertRecordToGlideRecord, + convertGlideRecordToRecord, } from ".."; import { ValkeyCluster } from "../../utils/TestUtils"; import { runBaseTests } from "./SharedTests"; @@ -323,6 +324,27 @@ describe("GlideClusterClient", () => { "OK", convertRecordToGlideRecord({ timeout: "1000" }), ]); + + if (!cluster.checkIfServerVersionLessThan("7.0.0")) { + const transaction = new ClusterTransaction() + .configSet({ + timeout: "2000", + "cluster-node-timeout": "16000", + }) + .configGet(["timeout", "cluster-node-timeout"]); + const result = await client.exec(transaction); + const convertedResult = [ + result[0], + convertGlideRecordToRecord(result[1]), + ]; + expect(convertedResult).toEqual([ + "OK", + { + timeout: "2000", + "cluster-node-timeout": "16000", + }, + ]); + } }, TIMEOUT, ); diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index 7ed788f990..5ba0ebbed4 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -1206,9 +1206,9 @@ export function runBaseTests(config: { ); it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])( - `config get and config set with timeout parameter_%p`, + `config get and config set with multiple parameters_%p`, async (protocol) => { - await runTest(async (client: BaseClient) => { + await runTest(async (client: BaseClient, cluster) => { const prevTimeout = (await client.configGet([ "timeout", ])) as Record; @@ -1225,6 +1225,37 @@ export function runBaseTests(config: { timeout: prevTimeout["timeout"], }), ).toEqual("OK"); + + if (!cluster.checkIfServerVersionLessThan("7.0.0")) { + const prevTimeout = (await client.configGet([ + "timeout", + ])) as Record; + const prevClusterNodeTimeout = (await client.configGet([ + "cluster-node-timeout", + ])) as Record; + expect( + await client.configSet({ + timeout: "1000", + "cluster-node-timeout": "16000", + }), + ).toEqual("OK"); + const currParameterValues = (await client.configGet([ + "timeout", + "cluster-node-timeout", + ])) as Record; + expect(currParameterValues).toEqual({ + timeout: "1000", + "cluster-node-timeout": "16000", + }); + /// Revert to the previous configuration + expect( + await client.configSet({ + timeout: prevTimeout["timeout"], + "cluster-node-timeout": + prevClusterNodeTimeout["cluster-node-timeout"], + }), + ).toEqual("OK"); + } }, protocol); }, config.timeout, diff --git a/python/python/glide/async_commands/cluster_commands.py b/python/python/glide/async_commands/cluster_commands.py index ab73e5ef0e..e1b9135221 100644 --- a/python/python/glide/async_commands/cluster_commands.py +++ b/python/python/glide/async_commands/cluster_commands.py @@ -204,6 +204,7 @@ async def config_get( ) -> TClusterResponse[Dict[bytes, bytes]]: """ Get the values of configuration parameters. + Starting from server version 7, command supports multiple parameters. See https://valkey.io/commands/config-get/ for details. Args: @@ -236,6 +237,7 @@ async def config_set( ) -> TOK: """ Set configuration parameters to the specified values. + Starting from server version 7, command supports multiple parameters. See https://valkey.io/commands/config-set/ for details. Args: diff --git a/python/python/glide/async_commands/standalone_commands.py b/python/python/glide/async_commands/standalone_commands.py index b02b29a77b..4595d894dc 100644 --- a/python/python/glide/async_commands/standalone_commands.py +++ b/python/python/glide/async_commands/standalone_commands.py @@ -153,6 +153,7 @@ async def ping(self, message: Optional[TEncodable] = None) -> bytes: async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]: """ Get the values of configuration parameters. + Starting from server version 7, command supports multiple parameters. See https://valkey.io/commands/config-get/ for details. Args: @@ -175,6 +176,7 @@ async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]: async def config_set(self, parameters_map: Mapping[TEncodable, TEncodable]) -> TOK: """ Set configuration parameters to the specified values. + Starting from server version 7, command supports multiple parameters. See https://valkey.io/commands/config-set/ for details. Args: diff --git a/python/python/glide/async_commands/transaction.py b/python/python/glide/async_commands/transaction.py index 9bc7879c65..9b84c6ac4e 100644 --- a/python/python/glide/async_commands/transaction.py +++ b/python/python/glide/async_commands/transaction.py @@ -313,6 +313,7 @@ def delete(self: TTransaction, keys: List[TEncodable]) -> TTransaction: def config_get(self: TTransaction, parameters: List[TEncodable]) -> TTransaction: """ Get the values of configuration parameters. + Starting from server version 7, command supports multiple parameters. See https://valkey.io/commands/config-get/ for details. Args: @@ -329,6 +330,7 @@ def config_set( ) -> TTransaction: """ Set configuration parameters to the specified values. + Starting from server version 7, command supports multiple parameters. See https://valkey.io/commands/config-set/ for details. Args: diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index 3db7e965db..bbd1060a40 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -855,6 +855,46 @@ async def test_config_get_set(self, glide_client: TGlideClient): == OK ) + if not await check_if_server_version_lt(glide_client, "7.0.0"): + previous_timeout = await glide_client.config_get(["timeout"]) + previous_cluster_node_timeout = await glide_client.config_get( + ["cluster-node-timeout"] + ) + assert ( + await glide_client.config_set( + {"timeout": "2000", "cluster-node-timeout": "16000"} + ) + == OK + ) + assert await glide_client.config_get( + ["timeout", "cluster-node-timeout"] + ) == { + b"timeout": b"2000", + b"cluster-node-timeout": b"16000", + } + # revert changes to previous timeout + previous_timeout_decoded = convert_bytes_to_string_object(previous_timeout) + previous_cluster_node_timeout_decoded = convert_bytes_to_string_object( + previous_cluster_node_timeout + ) + assert isinstance(previous_timeout_decoded, dict) + assert isinstance(previous_cluster_node_timeout_decoded, dict) + assert isinstance(previous_timeout_decoded["timeout"], str) + assert isinstance( + previous_cluster_node_timeout_decoded["cluster-node-timeout"], str + ) + assert ( + await glide_client.config_set( + { + "timeout": previous_timeout_decoded["timeout"], + "cluster-node-timeout": previous_cluster_node_timeout_decoded[ + "cluster-node-timeout" + ], + } + ) + == OK + ) + @pytest.mark.parametrize("cluster_mode", [True]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) async def test_config_get_with_wildcard_and_multi_node_route( diff --git a/python/python/tests/test_transaction.py b/python/python/tests/test_transaction.py index 7affca711b..fe0033c9b4 100644 --- a/python/python/tests/test_transaction.py +++ b/python/python/tests/test_transaction.py @@ -271,6 +271,11 @@ async def transaction_test( args.append(OK) transaction.config_get(["timeout"]) args.append({b"timeout": b"1000"}) + if not await check_if_server_version_lt(glide_client, "7.0.0"): + transaction.config_set({"timeout": "2000", "cluster-node-timeout": "16000"}) + args.append(OK) + transaction.config_get(["timeout", "cluster-node-timeout"]) + args.append({b"timeout": b"2000", b"cluster-node-timeout": b"16000"}) transaction.hset(key4, {key: value, key2: value2}) args.append(2)