Review funkt
This commit is contained in:
18
node_modules/bullmq/dist/cjs/commands/includes/batches.lua
generated
vendored
Normal file
18
node_modules/bullmq/dist/cjs/commands/includes/batches.lua
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
--[[
|
||||
Function to loop in batches.
|
||||
Just a bit of warning, some commands as ZREM
|
||||
could receive a maximum of 7000 parameters per call.
|
||||
]]
|
||||
|
||||
local function batches(n, batchSize)
|
||||
local i = 0
|
||||
|
||||
return function()
|
||||
local from = i * batchSize + 1
|
||||
i = i + 1
|
||||
if (from <= n) then
|
||||
local to = math.min(from + batchSize - 1, n)
|
||||
return from, to
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user