summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2015-05-22 22:58:27 -0400
committerAndy McCurdy <andy@andymccurdy.com>2015-05-22 22:58:27 -0400
commit81429b44acff3f238a212a1651241b49cde76c85 (patch)
treea8537c99f6096d29f5ef3356f222d99d1616fade
parenta4d6e9fd06c5fe9e38eb8cf2cd32fff75b7d24b1 (diff)
parent6935a30c680a81659b2e02b9f9220517cdfd637b (diff)
downloadredis-py-81429b44acff3f238a212a1651241b49cde76c85.tar.gz
Merge pull request #620 from cwilkes/master
Support multiple keys for pfcount call
-rwxr-xr-xredis/client.py6
-rw-r--r--tests/test_commands.py4
2 files changed, 7 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py
index 8b5a3fa..7c6a329 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -1813,12 +1813,12 @@ class StrictRedis(object):
"Adds the specified elements to the specified HyperLogLog."
return self.execute_command('PFADD', name, *values)
- def pfcount(self, name):
+ def pfcount(self, *sources):
"""
Return the approximated cardinality of
- the set observed by the HyperLogLog at key.
+ the set observed by the HyperLogLog at key(s).
"""
- return self.execute_command('PFCOUNT', name)
+ return self.execute_command('PFCOUNT', *sources)
def pfmerge(self, dest, *sources):
"Merge N different HyperLogLogs into a single one."
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 286ea04..2e104ed 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1106,6 +1106,10 @@ class TestRedisCommands(object):
members = set([b('1'), b('2'), b('3')])
r.pfadd('a', *members)
assert r.pfcount('a') == len(members)
+ members_b = set([b('2'), b('3'), b('4')])
+ r.pfadd('b', *members_b)
+ assert r.pfcount('b') == len(members_b)
+ assert r.pfcount('a', 'b') == len(members_b.union(members))
@skip_if_server_version_lt('2.8.9')
def test_pfmerge(self, r):