Sha256: c2accdd752f1a1b27ffe0f938ec262a6a750628caf455b2593f95815ef78de2c

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

module SidekiqUniqueJobs
  module Unlockable
    module_function

    def unlock(item)
      unlock_by_key(item[UNIQUE_DIGEST_KEY], item[JID_KEY])
    end

    def unlock_by_key(unique_key, jid, redis_pool = nil)
      return false unless Scripts::ReleaseLock.execute(redis_pool, unique_key, jid)
      after_unlock(jid)
    end

    def after_unlock(jid)
      ensure_job_id_removed(jid)
    end

    def ensure_job_id_removed(jid)
      Sidekiq.redis { |redis| redis.hdel(SidekiqUniqueJobs::HASH_KEY, jid) }
    end

    def logger
      SidekiqUniqueJobs.logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-5.0.2 lib/sidekiq_unique_jobs/unlockable.rb
sidekiq-unique-jobs-5.0.1 lib/sidekiq_unique_jobs/unlockable.rb