summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-redis/redis/cluster_commands.go
blob: dff62c902d03dc9db86592fc82c228b45f969e84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
}