Skip to content

Commit

Permalink
Adjust docs to match existing format
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-congo committed May 2, 2024
1 parent faa2509 commit 75f4552
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
34 changes: 16 additions & 18 deletions python/python/glide/async_commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,26 +1133,25 @@ async def lpop_count(self, key: str, count: int) -> Optional[List[str]]:
async def blpop(self, keys: List[str], timeout: float) -> Optional[List[str]]:
"""
Pops an element from the head of the first list that is non-empty, with the given keys being checked in the
order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.
order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.
When in cluster mode, all keys must map to the same hash slot.
See https://valkey.io/commands/blpop for details.
Notes:
1: BLPOP is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
2: When in cluster mode, all keys must map to the same hash slot.
BLPOP is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
Args:
keys (List[str]): The keys of the lists to pop from.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of `0` will block indefinitely.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.
Returns:
Optional[List[str]]: A two-element list containing the `key` from which the element was popped and the `value` of the
popped element, formatted as `[key, value]`. If no element could be popped and the timeout expired, returns `None`.
Optional[List[str]]: A two-element list containing the key from which the element was popped and the value of the
popped element, formatted as `[key, value]`. If no element could be popped and the `timeout` expired, returns None.
Examples:
>>> await client.blpop(["list1", "list2"], 0.5)
["list1", "element"]
["list1", "element"] # "element" was popped from the head of the list with key "list1"
"""
return cast(
Optional[List[str]],
Expand Down Expand Up @@ -1324,26 +1323,25 @@ async def rpop_count(self, key: str, count: int) -> Optional[List[str]]:
async def brpop(self, keys: List[str], timeout: float) -> Optional[List[str]]:
"""
Pops an element from the tail of the first list that is non-empty, with the given keys being checked in the
order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.
order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.
When in cluster mode, all keys must map to the same hash slot.
See https://valkey.io/commands/brpop for details.
Notes:
1: BRPOP is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
2: When in cluster mode, all keys must map to the same hash slot.
BRPOP is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
Args:
keys (List[str]): The keys of the lists to pop from.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of `0` will block indefinitely.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.
Returns:
Optional[List[str]]: A two-element list containing the `key` from which the element was popped and the `value` of the
popped element, formatted as `[key, value]`. If no element could be popped and the timeout expired, returns `None`.
Optional[List[str]]: A two-element list containing the key from which the element was popped and the value of the
popped element, formatted as `[key, value]`. If no element could be popped and the `timeout` expired, returns None.
Examples:
>>> await client.brpop(["list1", "list2"], 0.5)
["list1", "element"]
["list1", "element"] # "element" was popped from the tail of the list with key "list1"
"""
return cast(
Optional[List[str]],
Expand Down
26 changes: 10 additions & 16 deletions python/python/glide/async_commands/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,22 +730,19 @@ def lpop_count(self: TTransaction, key: str, count: int) -> TTransaction:
def blpop(self: TTransaction, keys: List[str], timeout: float) -> TTransaction:
"""
Pops an element from the head of the first list that is non-empty, with the given keys being checked in the
order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.
order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.
See https://valkey.io/commands/blpop for details.
Note: BLPOP is a client blocking command, see
https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best
practices.
BLPOP is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
Args:
keys (List[str]): The keys of the lists to pop from.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of `0` will block indefinitely.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.
Command response:
Optional[List[str]]: A two-element list containing the `key` from which the element was popped and the `value` of the
popped element, formatted as `[key, value]`. If no element could be popped and the timeout expired, returns `None`.
Optional[List[str]]: A two-element list containing the key from which the element was popped and the value of the
popped element, formatted as `[key, value]`. If no element could be popped and the `timeout` expired, returns None.
"""
return self.append_command(RequestType.Blpop, keys + [str(timeout)])

Expand Down Expand Up @@ -858,22 +855,19 @@ def rpop_count(self: TTransaction, key: str, count: int) -> TTransaction:
def brpop(self: TTransaction, keys: List[str], timeout: float) -> TTransaction:
"""
Pops an element from the tail of the first list that is non-empty, with the given keys being checked in the
order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.
order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.
See https://valkey.io/commands/brpop for details.
Note: BRPOP is a client blocking command, see
https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best
practices.
BRPOP is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
Args:
keys (List[str]): The keys of the lists to pop from.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of `0` will block indefinitely.
timeout (float): The number of seconds to wait for a blocking operation to complete. A value of 0 will block indefinitely.
Command response:
Optional[List[str]]: A two-element list containing the `key` from which the element was popped and the `value` of the
popped element, formatted as `[key, value]`. If no element could be popped and the timeout expired, returns `None`.
Optional[List[str]]: A two-element list containing the key from which the element was popped and the value of the
popped element, formatted as `[key, value]`. If no element could be popped and the `timeout` expired, returns None.
"""
return self.append_command(RequestType.Brpop, keys + [str(timeout)])

Expand Down

0 comments on commit 75f4552

Please sign in to comment.