Skip to content

Commit

Permalink
update pending2ReadyScript to adapt to alibaba Cloud #12
Browse files Browse the repository at this point in the history
  • Loading branch information
HDT3213 committed Feb 12, 2024
1 parent 8cabcf8 commit 461d5a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
8 changes: 4 additions & 4 deletions delayqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`
Expand Down
File renamed without changes.

0 comments on commit 461d5a1

Please sign in to comment.