forked from mirror/redis
Implemented PFADD, PFCOUNT, PFMERGE
This commit is contained in:
parent
05394bee7c
commit
43603e1ea4
32
commands.go
32
commands.go
|
@ -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 {
|
||||
cmd := NewStatusCmd("BGREWRITEAOF")
|
||||
cmd._clusterKeyPos = 0
|
||||
|
|
|
@ -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() {
|
||||
|
||||
It("should BLPop", func() {
|
||||
|
|
Loading…
Reference in New Issue