Sha256: 409a26e524a756e7efbcb6327d6b3631006f79a4096b1cf965d25c3b5d8447c1

Contents?: true

Size: 612 Bytes

Versions: 2

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

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 { |conn| conn.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.6 lib/sidekiq_unique_jobs/unlockable.rb
sidekiq-unique-jobs-5.0.5 lib/sidekiq_unique_jobs/unlockable.rb