diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..56635ff --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Run Example", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}/example" + } + ] +} \ No newline at end of file diff --git a/delayqueue.go b/delayqueue.go index c54e624..8e81478 100644 --- a/delayqueue.go +++ b/delayqueue.go @@ -218,16 +218,16 @@ func (q *DelayQueue) SendDelayMsg(payload string, duration time.Duration, opts . const pending2ReadyScript = ` local msgs = redis.call('ZRangeByScore', KEYS[1], '0', ARGV[1]) -- get ready msg if (#msgs == 0) then return end -local args2 = {'LPush', KEYS[2]} -- push into ready +local args2 = {} -- keys to push into ready for _,v in ipairs(msgs) do table.insert(args2, v) if (#args2 == 4000) then - redis.call(unpack(args2)) - args2 = {'LPush', KEYS[2]} + redis.call('LPush', KEYS[2], unpack(args2)) + args2 = {} end end if (#args2 > 2) then - redis.call(unpack(args2)) + redis.call('LPush', KEYS[2], unpack(args2)) end redis.call('ZRemRangeByScore', KEYS[1], '0', ARGV[1]) -- remove msgs from pending ` diff --git a/exmaple/main.go b/example/main.go similarity index 100% rename from exmaple/main.go rename to example/main.go