File: cluster_commands.go

package info (click to toggle)
golang-github-go-redis-redis 6.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 736 kB
  • sloc: makefile: 20
file content (22 lines) | stat: -rw-r--r-- 376 bytes parent folder | download | duplicates (2)
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
}