From 4722ca2d3de13622a4210e64354b92fec191762f Mon Sep 17 00:00:00 2001 From: disc Date: Sat, 20 Mar 2021 11:56:17 +0200 Subject: [PATCH] Replaced blocking `KEYS XXX:*` command to non-blocking `SCAN XXX:*` More details: https://redis.io/commands/KEYS --- internal/rdb/inspect.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/rdb/inspect.go b/internal/rdb/inspect.go index 7f1d9ce..39830a8 100644 --- a/internal/rdb/inspect.go +++ b/internal/rdb/inspect.go @@ -172,9 +172,17 @@ func (r *RDB) CurrentStats(qname string) (*Stats, error) { } func (r *RDB) memoryUsage(qname string) (int64, error) { - keys, err := r.client.Keys(fmt.Sprintf("asynq:{%s}*", qname)).Result() - if err != nil { - return 0, err + var cursor uint64 + var keys []string + for { + data, cursor, err := r.client.Scan(cursor, fmt.Sprintf("asynq:{%s}*", qname), 100).Result() + if err != nil { + return 0, err + } + keys = append(keys, data...) + if cursor == 0 { + break + } } var usg int64 for _, k := range keys {