forked from mirror/redis
Add Cluster.DBSize
This commit is contained in:
parent
5294b5dae1
commit
0a7606651d
|
@ -0,0 +1,22 @@
|
||||||
|
package redis
|
||||||
|
|
||||||
|
import "sync/atomic"
|
||||||
|
|
||||||
|
func (c *ClusterClient) DBSize() *IntCmd {
|
||||||
|
cmd := NewIntCmd("dbsize")
|
||||||
|
var size int64
|
||||||
|
err := c.ForEachMaster(func(master *Client) error {
|
||||||
|
n, err := master.DBSize().Result()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
atomic.AddInt64(&size, n)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
cmd.setErr(err)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
cmd.val = size
|
||||||
|
return cmd
|
||||||
|
}
|
|
@ -475,11 +475,9 @@ var _ = Describe("ClusterClient", func() {
|
||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
for _, client := range cluster.masters() {
|
size, err := client.DBSize().Result()
|
||||||
size, err := client.DBSize().Result()
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(size).To(Equal(int64(0)))
|
||||||
Expect(size).To(Equal(int64(0)))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should CLUSTER SLOTS", func() {
|
It("should CLUSTER SLOTS", func() {
|
||||||
|
|
Loading…
Reference in New Issue