Sha256: a064c64059c32b89aff45bb1b55224421bcdf6e71239d5953c5d1d076b4a2a4e

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Unlockable
    module_function

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

    def unlock_by_key(unique_key, jid, redis_pool = nil)
      lock_released = Scripts::ReleaseLock.execute(redis_pool, unique_key, jid)
      ensure_job_id_removed(jid)
      lock_released
    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

1 entries across 1 versions & 1 rubygems

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