Sha256: 86fe4a0835054d81c0d0c753d09319f49c8d35e7f98fb7bad698b58ebccb4fe4

Contents?: true

Size: 1.89 KB

Versions: 74

Compression:

Stored size: 1.89 KB

Contents

redis.replicate_commands()
-------- BEGIN keys ---------
local live_version = KEYS[1]
local dead_version = KEYS[2]
-------- END keys ---------

--------  BEGIN injected arguments --------
local current_time = tonumber(ARGV[5])
local debug_lua    = ARGV[6] == "true"
local max_history  = tonumber(ARGV[7])
local script_name  = tostring(ARGV[8]) .. ".lua"
local redisversion = ARGV[9]
---------  END injected arguments ---------

--------  BEGIN local functions --------
<%= include_partial "shared/_common.lua" %>
<%= include_partial "shared/_upgrades.lua" %>
----------  END local functions ----------


local new_version   = redis.call("GET", live_version)
local old_version   = redis.call("GET", dead_version)
local redis_version = toversion(redisversion)
local upgraded      = 0
local del_cmd       = "DEL"

if redis_version["major"] >= 4 then del_cmd = "UNLINK"; end
--------  BEGIN delete.lua --------

log_debug("BEGIN upgrading from: ", old_version, "to:", new_version)

-- 1. Loop through all uniquejobs:jajshdahdas:GRABBED
local cursor = "0"
local per   = 50
repeat
  local pagination   = redis.call("SCAN", cursor, "MATCH", "*:GRABBED", "COUNT", per)
  local next_cursor  = pagination[1]
  local grabbed_keys = pagination[2]

  for _, grabbed in ipairs(grabbed_keys) do
    local locked_key = grabbed.gsub(":GRABBED", ":LOCKED")
    local locks      = redis.call("HGETALL", grabbed)

    if #locks == 0 then
      log_debug("No entries in:", grabbed)
    else
      log_debug("HMSET", locked_key, unpack(locks))
      redis.call("HMSET", locked_key, unpack(locks))
    end

    log_debug("DEL", grabbed)
    redis.call("DEL", grabbed)

    upgraded = upgraded + 1
  end

  cursor = next_cursor
  if cursor == "0" then
    log_debug("Looped through all grabbed keys, stopping iteration")
  end
until cursor == "0"



log_debug("END upgrading from: ", old_version, "to:", new_version)

return
--------  END delete.lua --------

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.29 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.24 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.23 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.22 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.21 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.20 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.19 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.18 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.17 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.16 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.15 lib/sidekiq_unique_jobs/lua/upgrade.lua
sidekiq-unique-jobs-7.1.14 lib/sidekiq_unique_jobs/lua/upgrade.lua