Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple keys for pfcount call #620

Merged
merged 1 commit into from
May 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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