From 76ceb282a906a40e23e9c05a3e8852584fc5bcfe Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Sat, 23 Nov 2019 08:24:16 -0800 Subject: [PATCH] Change the direction of list push/pop operations --- rdb.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rdb.go b/rdb.go index 5a4b692..d394c82 100644 --- a/rdb.go +++ b/rdb.go @@ -49,7 +49,7 @@ func (r *rdb) push(msg *taskMessage) error { return fmt.Errorf("command SADD %q %q failed: %v", allQueues, qname, err) } - err = r.client.RPush(qname, string(bytes)).Err() + err = r.client.LPush(qname, string(bytes)).Err() if err != nil { return fmt.Errorf("command RPUSH %q %q failed: %v", qname, string(bytes), err) @@ -60,8 +60,8 @@ func (r *rdb) push(msg *taskMessage) error { // dequeue blocks until there is a taskMessage available to be processed, // once available, it adds the task to "in progress" set and returns the task. func (r *rdb) dequeue(timeout time.Duration, keys ...string) (*taskMessage, error) { - // TODO(hibiken): Make BLPOP & SADD atomic. - res, err := r.client.BLPop(timeout, keys...).Result() + // TODO(hibiken): Make BRPOP & SADD atomic. + res, err := r.client.BRPop(timeout, keys...).Result() if err != nil { if err != redis.Nil { return nil, fmt.Errorf("command BLPOP %v %v failed: %v", timeout, keys, err)