Skip to content

Commit

Permalink
support multiple keys for pfcount call
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Wilkes committed May 22, 2015
1 parent a4d6e9f commit 6935a30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6935a30

Please sign in to comment.