mirror of
https://github.com/deanpcmad/sidekiq-limit_fetch.git
synced 2022-11-09 13:54:36 -05:00
Speed up the queue selector
This commit is contained in:
parent
7bf321fe20
commit
fcb90ae22a
1 changed files with 15 additions and 11 deletions
|
@ -54,19 +54,23 @@ module Sidekiq::LimitFetch::Global
|
||||||
|
|
||||||
for _, queue in ipairs(queues) do
|
for _, queue in ipairs(queues) do
|
||||||
if not blocking_mode or unblocked[queue] then
|
if not blocking_mode or unblocked[queue] then
|
||||||
local probed_key = namespace..'probed:'..queue
|
local probed_key = namespace..'probed:'..queue
|
||||||
local pause_key = namespace..'pause:'..queue
|
local pause_key = namespace..'pause:'..queue
|
||||||
local paused = redis.call('get', pause_key)
|
local limit_key = namespace..'limit:'..queue
|
||||||
|
local process_limit_key = namespace..'process_limit:'..queue
|
||||||
|
local block_key = namespace..'block:'..queue
|
||||||
|
|
||||||
|
local paused, limit, process_limit, can_block =
|
||||||
|
unpack(redis.call('mget',
|
||||||
|
pause_key,
|
||||||
|
limit_key,
|
||||||
|
process_limit_key,
|
||||||
|
block_key
|
||||||
|
))
|
||||||
|
|
||||||
if not paused then
|
if not paused then
|
||||||
local limit_key = namespace..'limit:'..queue
|
limit = tonumber(limit)
|
||||||
local limit = tonumber(redis.call('get', limit_key))
|
process_limit = tonumber(process_limit)
|
||||||
|
|
||||||
local process_limit_key = namespace..'process_limit:'..queue
|
|
||||||
local process_limit = tonumber(redis.call('get', process_limit_key))
|
|
||||||
|
|
||||||
local block_key = namespace..'block:'..queue
|
|
||||||
local can_block = redis.call('get', block_key)
|
|
||||||
|
|
||||||
if can_block or limit then
|
if can_block or limit then
|
||||||
locks = redis.call('llen', probed_key)
|
locks = redis.call('llen', probed_key)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue