Sha256: bb9fc0aef37bd7ef2b948a24715a2109b77e244b964de02a3444bd6a82ec73c0

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

local function delete_from_sorted_set(name, digest)
  local score  = redis.call("ZSCORE", "uniquejobs:digests", digest)
  local total  = redis.call("ZCARD", name)
  local per    = 50

  for offset = 0, total, per do
    local items

    if score then
      items = redis.call("ZRANGE", name, score, "+inf", "BYSCORE", "LIMIT", offset, per)
    else
      items = redis.call("ZRANGE", name, offset, offset + per -1)
    end

    if #items == 0 then
      break
    end

    for _, item in pairs(items) do
      if string.find(item, digest) then
        redis.call("ZREM", name, item)

        return item
      end
    end
  end

  return nil
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-8.0.10 lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua