-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add support for BZMPOP #1851
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
Add support for BZMPOP #1851
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| import hashlib | ||
| import time | ||
| import warnings | ||
| from typing import List, Optional | ||
|
|
||
| from redis.exceptions import ConnectionError, DataError, NoScriptError, RedisError | ||
|
|
||
|
|
@@ -3255,6 +3256,39 @@ def bzpopmin(self, keys, timeout=0): | |
| keys.append(timeout) | ||
| return self.execute_command("BZPOPMIN", *keys) | ||
|
|
||
| def bzmpop( | ||
| self, | ||
| timeout: float, | ||
| num_keys: int, | ||
| keys: List[str], | ||
| min: Optional[bool] = False, | ||
| max: Optional[bool] = False, | ||
| count: Optional[int] = 1, | ||
| ) -> Optional[list]: | ||
| """ | ||
| Pop ``count`` values (default 1) off of the first non-empty sorted set | ||
| named in the ``keys`` list. | ||
|
|
||
| If none of the sorted sets in ``keys`` has a value to pop, | ||
| then block for ``timeout`` seconds, or until a member gets added | ||
| to one of the sorted sets. | ||
|
|
||
| If timeout is 0, then block indefinitely. | ||
|
|
||
| For more information check https://redis.io/commands/bzmpop | ||
| """ | ||
| args = [timeout, num_keys, *keys] | ||
| if (min and max) or (not min and not max): | ||
| raise DataError | ||
|
||
| elif min: | ||
| args.append("MIN") | ||
| else: | ||
| args.append("MAX") | ||
| if count != 1: | ||
|
||
| args.extend(["COUNT", count]) | ||
|
|
||
| return self.execute_command("BZMPOP", *args) | ||
|
|
||
| def _zrange( | ||
| self, | ||
| command, | ||
|
|
||
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.
num_keys should probably be numkeys - given the help text