Merge pull request #183 from lcosmin/master

Implemented PFADD, PFCOUNT, PFMERGE
This commit is contained in:
Vladimir Mihailenco 2015-11-04 13:33:58 +02:00
commit a2dba7df0c
2 changed files with 53 additions and 0 deletions

View File

@ -1332,6 +1332,38 @@ func (c *commandable) ZUnionStore(dest string, store ZStore, keys ...string) *In
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
func (c *commandable) PFAdd(key string, fields ...string) *IntCmd {
args := make([]interface{}, 2+len(fields))
args[0] = "PFADD"
args[1] = key
for i, field := range fields {
args[2+i] = field
}
cmd := NewIntCmd(args...)
c.Process(cmd)
return cmd
}
func (c *commandable) PFCount(key string) *IntCmd {
cmd := NewIntCmd("PFCOUNT", key)
c.Process(cmd)
return cmd
}
func (c *commandable) PFMerge(dest string, keys ...string) *StatusCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "PFMERGE"
args[1] = dest
for i, key := range keys {
args[2+i] = key
}
cmd := NewStatusCmd(args...)
c.Process(cmd)
return cmd
}
//------------------------------------------------------------------------------
func (c *commandable) BgRewriteAOF() *StatusCmd { func (c *commandable) BgRewriteAOF() *StatusCmd {
cmd := NewStatusCmd("BGREWRITEAOF") cmd := NewStatusCmd("BGREWRITEAOF")
cmd._clusterKeyPos = 0 cmd._clusterKeyPos = 0

View File

@ -1190,6 +1190,27 @@ var _ = Describe("Commands", func() {
}) })
Describe("hyperloglog", func() {
It("should PFMerge", func() {
pfAdd := client.PFAdd("hll1", "1", "2", "3", "4", "5")
Expect(pfAdd.Err()).NotTo(HaveOccurred())
pfCount := client.PFCount("hll1")
Expect(pfCount.Err()).NotTo(HaveOccurred())
Expect(pfCount.Val()).To(Equal(int64(5)))
pfAdd = client.PFAdd("hll2", "a", "b", "c", "d", "e")
Expect(pfAdd.Err()).NotTo(HaveOccurred())
pfMerge := client.PFMerge("hllMerged", "hll1", "hll2")
Expect(pfMerge.Err()).NotTo(HaveOccurred())
pfCount = client.PFCount("hllMerged")
Expect(pfCount.Err()).NotTo(HaveOccurred())
Expect(pfCount.Val()).To(Equal(int64(10)))
})
})
Describe("lists", func() { Describe("lists", func() {
It("should BLPop", func() { It("should BLPop", func() {