1
0
Fork 0
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:
brainopia 2014-03-24 13:07:37 +04:00
parent 7bf321fe20
commit fcb90ae22a

View file

@ -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)