mirror of
https://github.com/HDT3213/delayqueue.git
synced 2025-10-05 07:06:53 +08:00
update pending2ReadyScript to adapt to alibaba Cloud #12
This commit is contained in:
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -218,16 +218,16 @@ func (q *DelayQueue) SendDelayMsg(payload string, duration time.Duration, opts .
|
|||||||
const pending2ReadyScript = `
|
const pending2ReadyScript = `
|
||||||
local msgs = redis.call('ZRangeByScore', KEYS[1], '0', ARGV[1]) -- get ready msg
|
local msgs = redis.call('ZRangeByScore', KEYS[1], '0', ARGV[1]) -- get ready msg
|
||||||
if (#msgs == 0) then return end
|
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
|
for _,v in ipairs(msgs) do
|
||||||
table.insert(args2, v)
|
table.insert(args2, v)
|
||||||
if (#args2 == 4000) then
|
if (#args2 == 4000) then
|
||||||
redis.call(unpack(args2))
|
redis.call('LPush', KEYS[2], unpack(args2))
|
||||||
args2 = {'LPush', KEYS[2]}
|
args2 = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (#args2 > 2) then
|
if (#args2 > 2) then
|
||||||
redis.call(unpack(args2))
|
redis.call('LPush', KEYS[2], unpack(args2))
|
||||||
end
|
end
|
||||||
redis.call('ZRemRangeByScore', KEYS[1], '0', ARGV[1]) -- remove msgs from pending
|
redis.call('ZRemRangeByScore', KEYS[1], '0', ARGV[1]) -- remove msgs from pending
|
||||||
`
|
`
|
||||||
|
Reference in New Issue
Block a user