blob: 1f0bae067ae65a24cd313a0073e25747b0240bb9 [file] [log] [blame]
Joey Armstronge8c091f2023-01-17 16:56:26 -05001package redis
2
3import (
4 "context"
5 "sync/atomic"
6)
7
8func (c *ClusterClient) DBSize(ctx context.Context) *IntCmd {
9 cmd := NewIntCmd(ctx, "dbsize")
10 var size int64
11 err := c.ForEachMaster(ctx, func(ctx context.Context, master *Client) error {
12 n, err := master.DBSize(ctx).Result()
13 if err != nil {
14 return err
15 }
16 atomic.AddInt64(&size, n)
17 return nil
18 })
19 if err != nil {
20 cmd.SetErr(err)
21 return cmd
22 }
23 cmd.val = size
24 return cmd
25}