diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-08-15 13:44:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-15 13:44:41 +0300 |
commit | 37e7c093cbeaf7133d5dd7189563d5c15da8d12b (patch) | |
tree | 7b54fa0398b5273ab1214b69c3c32bc33f79e760 /redis | |
parent | 2789f08dfb7192f112aa0fc8cec6738dfb1b3a08 (diff) | |
download | redis-py-37e7c093cbeaf7133d5dd7189563d5c15da8d12b.tar.gz |
implementing the LMOVE and BLMOVE commands (#1504)
Diffstat (limited to 'redis')
-rwxr-xr-x | redis/client.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py index 3c3ab7f..a80012a 100755 --- a/redis/client.py +++ b/redis/client.py @@ -581,8 +581,8 @@ class Redis: """ RESPONSE_CALLBACKS = { **string_keys_to_dict( - 'AUTH COPY EXPIRE EXPIREAT HEXISTS HMSET MOVE MSETNX PERSIST ' - 'PSETEX RENAMENX SISMEMBER SMOVE SETEX SETNX', + 'AUTH COPY EXPIRE EXPIREAT HEXISTS HMSET LMOVE BLMOVE MOVE ' + 'MSETNX PERSIST PSETEX RENAMENX SISMEMBER SMOVE SETEX SETNX', bool ), **string_keys_to_dict( @@ -1851,6 +1851,23 @@ class Redis: "Returns a list of keys matching ``pattern``" return self.execute_command('KEYS', pattern) + def lmove(self, first_list, second_list, src="LEFT", dest="RIGHT"): + """ + Atomically returns and removes the first/last element of a list, + pushing it as the first/last element on the destination list. + Returns the element being popped and pushed. + """ + params = [first_list, second_list, src, dest] + return self.execute_command("LMOVE", *params) + + def blmove(self, first_list, second_list, timeout, + src="LEFT", dest="RIGHT"): + """ + Blocking version of lmove. + """ + params = [first_list, second_list, src, dest, timeout] + return self.execute_command("BLMOVE", *params) + def mget(self, keys, *args): """ Returns a list of values ordered identically to ``keys`` |