From 53d9b01461853e4f4ea6b197e18ab55dbc1e6179 Mon Sep 17 00:00:00 2001 From: Shoham Elias Date: Wed, 31 Jan 2024 13:43:35 +0000 Subject: [PATCH] Fix transaction doc to fit RESP3 --- node/src/Transaction.ts | 22 +++++++-------- .../glide/async_commands/transaction.py | 28 +++++++++---------- python/python/tests/test_transaction.py | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index 2568dc2292..b96d6c819c 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -221,7 +221,7 @@ export class BaseTransaction { * @param key - The key to increment its value. * @param amount - The amount to increment. * - * Command Response - the value of `key` after the increment as string. + * Command Response - the value of `key` after the increment. * An error is raised if `key` contains a value of the wrong type, * or the current key content is not parsable as a double precision floating point number. * @@ -269,7 +269,7 @@ export class BaseTransaction { * * @param parameters - A list of configuration parameter names to retrieve values for. * - * Command Response - A list of values corresponding to the configuration parameters. + * Command Response - A map of values corresponding to the configuration parameters. * */ public configGet(parameters: string[]) { @@ -351,8 +351,8 @@ export class BaseTransaction { * @param key - The key of the hash. * @param field - The field to check in the hash stored at `key`. * - * Command Response - 1 if the hash contains `field`. If the hash does not contain `field`, or if `key` does not exist, - * the command response will be 0. + * Command Response - `true` if the hash contains `field`. If the hash does not contain `field`, or if `key` does not exist, + * the command response will be `false`. */ public hexists(key: string, field: string) { this.commands.push(createHExists(key, field)); @@ -363,8 +363,8 @@ export class BaseTransaction { * * @param key - The key of the hash. * - * Command Response - a list of fields and their values stored in the hash. Every field name in the list is followed by its value. - * If `key` does not exist, it returns an empty list. + * Command Response - a map of fields and their values stored in the hash. Every field name in the map is followed by its value. + * If `key` does not exist, it returns an empty map. * If `key` holds a value that is not a hash, an error is raised. */ public hgetall(key: string) { @@ -397,7 +397,7 @@ export class BaseTransaction { * @param amount - The amount to increment. * @param field - The field in the hash stored at `key` to increment its value. * - * Command Response - the value of `field` in the hash stored at `key` after the increment as string. + * Command Response - the value of `field` in the hash stored at `key` after the increment. * An error is raised if `key` contains a value of the wrong type * or the current field content is not parsable as a double precision floating point number. * @@ -626,7 +626,7 @@ export class BaseTransaction { * @param seconds - The timeout in seconds. * @param option - The expire option. * - * Command Response - 1 if the timeout was set. 0 if the timeout was not set. e.g. key doesn't exist, + * Command Response - `true` if the timeout was set. `false` if the timeout was not set. e.g. key doesn't exist, * or operation skipped due to the provided arguments. */ public expire(key: string, seconds: number, option?: ExpireOptions) { @@ -643,7 +643,7 @@ export class BaseTransaction { * @param unixSeconds - The timeout in an absolute Unix timestamp. * @param option - The expire option. * - * Command Response - 1 if the timeout was set. 0 if the timeout was not set. e.g. key doesn't exist, + * Command Response - `true` if the timeout was set. `false` if the timeout was not set. e.g. key doesn't exist, * or operation skipped due to the provided arguments. */ public expireAt(key: string, unixSeconds: number, option?: ExpireOptions) { @@ -660,7 +660,7 @@ export class BaseTransaction { * @param milliseconds - The timeout in milliseconds. * @param option - The expire option. * - * Command Response - 1 if the timeout was set. 0 if the timeout was not set. e.g. key doesn't exist, + * Command Response - `true` if the timeout was set. `false` if the timeout was not set. e.g. key doesn't exist, * or operation skipped due to the provided arguments. */ public pexpire(key: string, milliseconds: number, option?: ExpireOptions) { @@ -677,7 +677,7 @@ export class BaseTransaction { * @param unixMilliseconds - The timeout in an absolute Unix timestamp. * @param option - The expire option. * - * Command Response - 1 if the timeout was set. 0 if the timeout was not set. e.g. key doesn't exist, + * Command Response - `true` if the timeout was set. `false` if the timeout was not set. e.g. key doesn't exist, * or operation skipped due to the provided arguments. */ public pexpireAt( diff --git a/python/python/glide/async_commands/transaction.py b/python/python/glide/async_commands/transaction.py index 1ac70203ae..d7ec7190ab 100644 --- a/python/python/glide/async_commands/transaction.py +++ b/python/python/glide/async_commands/transaction.py @@ -115,7 +115,7 @@ def config_get(self, parameters: List[str]): parameters (List[str]): A list of configuration parameter names to retrieve values for. Command response: - List[str]: A list of values corresponding to the configuration parameters. + Dict[str, str]: A dictionary of values corresponding to the configuration parameters. """ self.append_command(RequestType.ConfigGet, parameters) @@ -229,8 +229,8 @@ def incrbyfloat(self, key: str, amount: float): amount (float) : The amount to increment. Command response: - str: The value of key after the increment. An error is returned if the key contains a value - of the wrong type. + float: The value of key after the increment. The transaction fails if the key contains a value + of the wrong type. """ self.append_command(RequestType.IncrByFloat, [key, str(amount)]) @@ -341,7 +341,7 @@ def hincrbyfloat(self, key: str, field: str, amount: float): Use a negative value to decrement. Returns: - str: The value of the specified field in the hash stored at `key` after the increment as a string. + float: The value of the specified field in the hash stored at `key` after the increment as a string. The transaction fails if `key` contains a value of the wrong type or the current field content is not parsable as a double precision floating point number. """ @@ -356,8 +356,8 @@ def hexists(self, key: str, field: str): field (str): The field to check in the hash stored at `key`. Command response: - int: Returns 1 if the hash contains the specified field. If the hash does not contain the field, - or if the key does not exist, it returns 0. + bool: Returns 'True' if the hash contains the specified field. If the hash does not contain the field, + or if the key does not exist, it returns 'False'. If `key` holds a value that is not a hash, the transaction fails with an error. """ self.append_command(RequestType.HashExists, [key, field]) @@ -381,9 +381,9 @@ def hgetall(self, key: str): key (str): The key of the hash. Command response: - List[str]: A list of fields and their values stored in the hash. Every field name in the list is followed by - its value. If `key` does not exist, it returns an empty list. - If `key` holds a value that is not a hash , the transaction fails. + Dict[str, str]: A dictionary of fields and their values stored in the hash. Every field name in the list is followed by + its value. If `key` does not exist, it returns an empty dictionary. + If `key` holds a value that is not a hash, the transaction fails with an error. """ self.append_command(RequestType.HashGetAll, [key]), @@ -552,7 +552,7 @@ def smembers(self, key: str): key (str): The key from which to retrieve the set members. Commands response: - List[str]: A list of all members of the set. + Set[str]: A set of all members of the set. If `key` does not exist an empty list will be returned. If `key` holds a value that is not a set, the transaction fails. """ @@ -670,7 +670,7 @@ def expire(self, key: str, seconds: int, option: Optional[ExpireOptions] = None) option (Optional[ExpireOptions]): The expire option. Commands response: - int: 1 if the timeout was set, 0 if the timeout was not set (e.g., the key doesn't exist or the operation is + bool: 'True' if the timeout was set, 'False' if the timeout was not set (e.g., the key doesn't exist or the operation is skipped due to the provided arguments). """ @@ -697,7 +697,7 @@ def expireat( option (Optional[ExpireOptions]): The expire option. Commands response: - int: 1 if the timeout was set, 0 if the timeout was not set (e.g., the key doesn't exist or the operation is + bool: 'True' if the timeout was set, 'False' if the timeout was not set (e.g., the key doesn't exist or the operation is skipped due to the provided arguments). """ args = ( @@ -723,7 +723,7 @@ def pexpire( option (Optional[ExpireOptions]): The expire option. Commands response: - int: 1 if the timeout was set, 0 if the timeout was not set (e.g., the key doesn't exist or the operation is + bool: 'True' if the timeout was set, 'False' if the timeout was not set (e.g., the key doesn't exist or the operation is skipped due to the provided arguments). """ @@ -752,7 +752,7 @@ def pexpireat( option (Optional[ExpireOptions]): The expire option. Commands response: - int: 1 if the timeout was set, 0 if the timeout was not set (e.g., the key doesn't exist or the operation is + bool: 'True' if the timeout was set, 'False' if the timeout was not set (e.g., the key doesn't exist or the operation is skipped due to the provided arguments). """ args = ( diff --git a/python/python/tests/test_transaction.py b/python/python/tests/test_transaction.py index 89b172913d..742bb294fc 100644 --- a/python/python/tests/test_transaction.py +++ b/python/python/tests/test_transaction.py @@ -109,7 +109,7 @@ def transaction_test( value2, 5, 10.5, - 1, + True, [value, None, value2], {key: value, key2: value2, key3: "10.5"}, 2,