2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-24 22:46:11 +08:00

Maintain a set of queue names in redis set

This commit is contained in:
Ken Hibino
2020-01-09 06:21:43 -08:00
parent d5970d9501
commit 5d431bc247
3 changed files with 24 additions and 8 deletions

View File

@@ -48,7 +48,12 @@ func (r *RDB) Enqueue(msg *base.TaskMessage) error {
return err
}
key := base.QueueKey(msg.Queue)
return r.client.LPush(key, string(bytes)).Err()
script := redis.NewScript(`
redis.call("LPUSH", KEYS[1], ARGV[1])
redis.call("SADD", KEYS[2], KEYS[1])
return 1
`)
return script.Run(r.client, []string{key, base.AllQueues}, string(bytes)).Err()
}
// Dequeue queries given queues in order and pops a task message if there