-
Notifications
You must be signed in to change notification settings - Fork 65
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 LMOVE and BLMOVE commands #1536
Conversation
>>> result = await client.lmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT) | ||
>>> assert result == "one" |
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.
>>> result = await client.lmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT) | |
>>> assert result == "one" | |
>>> await client.lmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT) | |
"one" |
>>> updated_array1 = await client.lrange("testKey1", 0, -1) | ||
>>> updated_array2 = await client.lrange("testKey2", 0, -1) | ||
>>> assert updated_array1 == ["two"] | ||
>>> assert updated_array2 == ["one", "three", "four"] |
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.
>>> updated_array1 = await client.lrange("testKey1", 0, -1) | |
>>> updated_array2 = await client.lrange("testKey2", 0, -1) | |
>>> assert updated_array1 == ["two"] | |
>>> assert updated_array2 == ["one", "three", "four"] | |
>>> await client.lrange("testKey1", 0, -1) | |
["two"] | |
>>> await client.lrange("testKey2", 0, -1) | |
["one", "three", "four"] |
>>> result = await client.blmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT, 0.1) | ||
>>> assert result == "one" | ||
>>> updated_array1 = await client.lrange("testKey1", 0, -1) | ||
>>> updated_array2 = await client.lrange("testKey2", 0, -1) | ||
>>> assert updated_array1 == ["two"] | ||
>>> assert updated_array2 == ["one", "three", "four"] |
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.
>>> result = await client.blmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT, 0.1) | |
>>> assert result == "one" | |
>>> updated_array1 = await client.lrange("testKey1", 0, -1) | |
>>> updated_array2 = await client.lrange("testKey2", 0, -1) | |
>>> assert updated_array1 == ["two"] | |
>>> assert updated_array2 == ["one", "three", "four"] | |
>>> await client.blmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT, 0.1) | |
"one" | |
>>> await client.lrange("testKey1", 0, -1) | |
["two"] | |
>>> await client.lrange("testKey2", 0, -1) | |
["one", "three", "four"] |
of the list stored at `destination` depending on `whereto`. | ||
`blmove` is the blocking variant of `lmove`. | ||
|
||
See https://redis.io/commands/blmove/ 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/blmove/ for details. | |
See https://valkey.io/commands/blmove/ for details. |
Notes: | ||
When in cluster mode, both `source` and `destination` must map to the same hash slot. | ||
|
||
See https://redis.io/commands/lmove/ 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/lmove/ for details. | |
See https://valkey.io/commands/lmove/ for details. |
1. When in cluster mode, both `source` and `destination` must map to the same hash slot. | ||
2. `blmove` is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices. | ||
|
||
See https://redis.io/commands/blmove/ 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/blmove/ for details. | |
See https://valkey.io/commands/blmove/ for details. |
depending on `wherefrom`, and pushes the element at the first/last element of the list | ||
stored at `destination` depending on `whereto`. | ||
|
||
See https://redis.io/commands/lmove/ 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/lmove/ for details. | |
See https://valkey.io/commands/lmove/ for details. |
wherefrom: ListDirection, | ||
whereto: ListDirection, |
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.
in python the syntax is:
wherefrom: ListDirection, | |
whereto: ListDirection, | |
where_from: ListDirection, | |
where_to: ListDirection, |
whereto (ListDirection): The direction to add the element to (`ListDirection.LEFT` or `ListDirection.RIGHT`). | ||
|
||
Returns: | ||
Optional[str]: The popped element, or `None` if `source` does not exist. |
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.
Optional[str]: The popped element, or `None` if `source` does not exist. | |
Optional[str]: The popped element, or None if `source` does not exist. |
self, | ||
source: str, | ||
destination: str, | ||
wherefrom: ListDirection, |
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.
same
Blocks the connection until it pops atomically and removes the left/right-most element to the | ||
list stored at `source` depending on `wherefrom`, and pushes the element at the first/last element | ||
of the list stored at `destination` depending on `whereto`. | ||
`blmove` is the blocking variant of `lmove`. |
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.
`blmove` is the blocking variant of `lmove`. | |
`BLMOVE` is the blocking variant of `LMOVE`. |
see other blocking commands
) -> Optional[str]: | ||
""" | ||
Atomically pops and removes the left/right-most element to the list stored at `source` | ||
depending on `wherefrom`, and pushes the element at the first/last element of the list |
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 you change as per Sho's suggestions, please update here too
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 add changelog entry
Notes: | ||
When in cluster mode, both `source` and `destination` must map to the same hash slot. |
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.
We don't add this to transction.
It is applicable to the entire transaction, rather than to a particular command(s) in it.
Please Add since section
Co-authored-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com>
Python: added LMOVE and BLMOVE commands Co-authored-by: Shoham Elias
No description provided.