lib/sidekiq/limit_fetch/global/selector.rb in sidekiq-limit_fetch-2.2.1 vs lib/sidekiq/limit_fetch/global/selector.rb in sidekiq-limit_fetch-2.2.2

- old
+ new

@@ -52,22 +52,26 @@ local process_locks local blocking_mode for _, queue in ipairs(queues) do if not blocking_mode or unblocked[queue] then - local probed_key = namespace..'probed:'..queue - local pause_key = namespace..'pause:'..queue - local paused = redis.call('get', pause_key) + local probed_key = namespace..'probed:'..queue + local pause_key = namespace..'pause:'..queue + local limit_key = namespace..'limit:'..queue + local process_limit_key = namespace..'process_limit:'..queue + local block_key = namespace..'block:'..queue - if not paused then - local limit_key = namespace..'limit:'..queue - local limit = tonumber(redis.call('get', limit_key)) + local paused, limit, process_limit, can_block = + unpack(redis.call('mget', + pause_key, + limit_key, + process_limit_key, + block_key + )) - 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 not paused then + limit = tonumber(limit) + process_limit = tonumber(process_limit) if can_block or limit then locks = redis.call('llen', probed_key) end