Skip to content

Commit

Permalink
redis nil
Browse files Browse the repository at this point in the history
  • Loading branch information
blackroot committed Dec 7, 2021
1 parent ada97ea commit 69aef72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion xdelay_queue/delay_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ func (dq *DelayQueue) AddJob(job *Job) error {
return errors.WithStack(err)
}

return redis.NewScript(`
err = redis.NewScript(`
redis.call("SET", KEYS[1], ARGV[1])
redis.call("ZADD", KEYS[2], ARGV[2], ARGV[3])
`).Run(dq.Client, []string{job.Id, <- dq.bucketNameChan}, value, float64(job.Delay), job.Id).Err()
if err == nil || errors.Is(err, redis.Nil) {
return nil
}
return errors.WithStack(err)
}

func (dq *DelayQueue) GetJob(topics []string) (*Job, error) {
Expand Down

0 comments on commit 69aef72

Please sign in to comment.