Skip to content

Commit

Permalink
Replaced blocking KEYS XXX:* command to non-blocking SCAN XXX:*
Browse files Browse the repository at this point in the history
  • Loading branch information
disc authored and hibiken committed Mar 20, 2021
1 parent 6a9d9fd commit 4722ca2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/rdb/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4722ca2

Please sign in to comment.