From 6935a30c680a81659b2e02b9f9220517cdfd637b Mon Sep 17 00:00:00 2001 From: Chris Wilkes Date: Fri, 22 May 2015 15:23:05 -0700 Subject: [PATCH] support multiple keys for pfcount call --- redis/client.py | 6 +++--- tests/test_commands.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/redis/client.py b/redis/client.py index 8b5a3faed2..7c6a329d98 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1813,12 +1813,12 @@ def pfadd(self, name, *values): "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 286ea04b25..2e104edbda 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1106,6 +1106,10 @@ def test_pfcount(self, r): 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):