Sha256: 2858a9caac3e623cb4030ef776c735af3e46a4b8ad0e06554124e965403856b5

Contents?: true

Size: 1.2 KB

Versions: 72

Compression:

Stored size: 1.2 KB

Contents

local function find_digest_in_queues(digest)
  local cursor = "0"
  local count  = 50
  local result = nil
  local found  = false

  repeat
    log_debug("searching all queues for a matching digest:", digest)
    local pagination  = redis.call("SCAN", cursor, "MATCH", "queue:*", "COUNT", count)
    local next_cursor = pagination[1]
    local queues      = pagination[2]

    for _, queue in ipairs(queues) do
      local per    = 50
      local total  = redis.call("LLEN", queue)
      local index  = 0

      log_debug("searching in:", queue,
                "for digest:", digest,
                "from:", index,
                "to:", total,
                "(per: " .. per .. ")",
                "cursor:", cursor)

      while (index < total) do
        local items = redis.call("LRANGE", queue, index, index + per -1)
        for _, item in pairs(items) do
          if string.find(item, digest) then
            log_debug("Found digest:", digest, "in queue:", queue)
            result = cjson.decode(item).queue
            found = true
            break
          end
        end
        index = index + per
      end
    end

    cursor = next_cursor
  until found == true or cursor == "0"

  return result
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.3 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.1.2 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.1.1 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.1.0 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.12 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.11 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.10 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.9 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.8 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.7 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.6 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.5 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.4 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.3 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.2 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.1 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.0 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.0.beta29 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.0.beta28 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua
sidekiq-unique-jobs-7.0.0.beta27 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua