-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: Added STRLEN command in python #1230
Conversation
0372ee7
to
27f8d54
Compare
|
||
Returns: | ||
int: The length of the string value stored at key. | ||
If `key` does not exist, it is interpreted as an empty list and 0 is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If `key` does not exist, it is interpreted as an empty list and 0 is returned. | |
If `key` does not exist, it is interpreted as an empty string and 0 is returned. |
|
||
Commands response: | ||
int: The length of the string value stored at key. | ||
If `key` does not exist, it is interpreted as an empty list and 0 is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If `key` does not exist, it is interpreted as an empty list and 0 is returned. | |
If `key` does not exist, it is interpreted as an empty string and 0 is returned. |
assert await redis_client.lpush(key1, value_list) == 4 | ||
with pytest.raises(RequestError) as e: | ||
assert await redis_client.strlen(key1) | ||
assert "Operation against a key holding the wrong kind of value" in str(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep in mind that different redis version return different error message
@@ -1042,6 +1042,24 @@ async def llen(self, key: str) -> int: | |||
""" | |||
return cast(int, await self._execute_command(RequestType.LLen, [key])) | |||
|
|||
async def strlen(self, key: str) -> int: | |||
""" | |||
Get the length of the string value stored at key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get the length of the string value stored at key. | |
Get the length of the string value stored at `key`. |
async def strlen(self, key: str) -> int: | ||
""" | ||
Get the length of the string value stored at key. | ||
See https://redis.io/commands/strlen/ for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://redis.io/commands/strlen/ for details. | |
See https://redis.io/commands/strlen/ for more details. |
See https://redis.io/commands/strlen/ for details. | ||
|
||
Args: | ||
key (str): The key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key (str): The key | |
key (str): The key to return its length. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix @shohamazon comments and consider changing the test not to test for the exact error message per @Yury-Fridlyand
5da2582
to
1090bf7
Compare
* Python: adds STRLEN command --------- Co-authored-by: Shoham Elias
* Python: adds STRLEN command --------- Co-authored-by: Shoham Elias
No description provided.