2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-11-10 11:31:58 +08:00

Replaced blocking KEYS XXX:* command to non-blocking SCAN XXX:*

More details: https://redis.io/commands/KEYS
This commit is contained in:
disc 2021-03-20 11:56:17 +02:00 committed by Ken Hibino
parent 6a9d9fd717
commit 4722ca2d3d

View File

@ -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 {