Merge pull request #229 from hongrich/pfcount-multiple-keys

Support multiple keys for the PFCOUNT command
This commit is contained in:
Vladimir Mihailenco 2015-12-24 11:03:19 +02:00
commit bdb48fd31c
2 changed files with 11 additions and 2 deletions

View File

@ -1340,8 +1340,13 @@ func (c *commandable) PFAdd(key string, fields ...string) *IntCmd {
return cmd return cmd
} }
func (c *commandable) PFCount(key string) *IntCmd { func (c *commandable) PFCount(keys ...string) *IntCmd {
cmd := NewIntCmd("PFCOUNT", key) args := make([]interface{}, 1+len(keys))
args[0] = "PFCOUNT"
for i, key := range keys {
args[1+i] = key
}
cmd := NewIntCmd(args...)
c.Process(cmd) c.Process(cmd)
return cmd return cmd
} }

View File

@ -1203,6 +1203,10 @@ var _ = Describe("Commands", func() {
pfCount = client.PFCount("hllMerged") pfCount = client.PFCount("hllMerged")
Expect(pfCount.Err()).NotTo(HaveOccurred()) Expect(pfCount.Err()).NotTo(HaveOccurred())
Expect(pfCount.Val()).To(Equal(int64(10))) Expect(pfCount.Val()).To(Equal(int64(10)))
pfCount = client.PFCount("hll1", "hll2")
Expect(pfCount.Err()).NotTo(HaveOccurred())
Expect(pfCount.Val()).To(Equal(int64(10)))
}) })
}) })