1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-02 10:07:07 -05:00
forgejo/vendor/github.com/go-redis/redis/v8/cluster_commands.go

26 lines
445 B
Go
Raw Normal View History

package redis
import (
"context"
"sync/atomic"
)
func (c *ClusterClient) DBSize(ctx context.Context) *IntCmd {
cmd := NewIntCmd(ctx, "dbsize")
var size int64
err := c.ForEachMaster(ctx, func(ctx context.Context, master *Client) error {
n, err := master.DBSize(ctx).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
}