aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-redis/redis/v7/cluster_commands.go
blob: c9b9b9de24756fc90b8e39afb286b71c8a71c9b6 (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
}