summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorAvital Fine <79420960+AvitalFineRedis@users.noreply.github.com>2021-07-29 16:41:55 +0300
committerGitHub <noreply@github.com>2021-07-29 16:41:55 +0300
commitfc69bd65494d7ac8d08e16ff38e06936ab6dcc02 (patch)
treeae6f2d886ff0f1f2b63118abd0a9267cb2301ba4 /redis/client.py
parent53fe4d3eae75cabfb635eae5ae9197efa0bf86c3 (diff)
downloadredis-py-fc69bd65494d7ac8d08e16ff38e06936ab6dcc02.tar.gz
zdiff and zdiffstore (#1518)
Diffstat (limited to 'redis/client.py')
-rwxr-xr-xredis/client.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py
index 33b0374..4e4ccc6 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -595,8 +595,8 @@ class Redis:
lambda r: r and set(r) or set()
),
**string_keys_to_dict(
- 'ZPOPMAX ZPOPMIN ZRANGE ZRANGEBYSCORE ZREVRANGE ZREVRANGEBYSCORE',
- zset_score_pairs
+ 'ZPOPMAX ZPOPMIN ZDIFF ZRANGE ZRANGEBYSCORE ZREVRANGE '
+ 'ZREVRANGEBYSCORE', zset_score_pairs
),
**string_keys_to_dict('BZPOPMIN BZPOPMAX', \
lambda r:
@@ -2932,6 +2932,24 @@ class Redis:
"""
return self.execute_command('ZCOUNT', name, min, max)
+ def zdiff(self, keys, withscores=False):
+ """
+ Returns the difference between the first and all successive input
+ sorted sets provided in ``keys``.
+ """
+ pieces = [len(keys), *keys]
+ if withscores:
+ pieces.append("WITHSCORES")
+ return self.execute_command("ZDIFF", *pieces)
+
+ def zdiffstore(self, dest, keys):
+ """
+ Computes the difference between the first and all successive input
+ sorted sets provided in ``keys`` and stores the result in ``dest``.
+ """
+ pieces = [len(keys), *keys]
+ return self.execute_command("ZDIFFSTORE", dest, *pieces)
+
def zincrby(self, name, amount, value):
"Increment the score of ``value`` in sorted set ``name`` by ``amount``"
return self.execute_command('ZINCRBY', name, amount, value)