Module: SidekiqUniqueJobs::Unlockable

Defined in:
lib/sidekiq_unique_jobs/unlockable.rb

Overview

Utility module to help manage unique keys in redis. Useful for deleting keys that for whatever reason wasn’t deleted

Author:

Class Method Summary collapse

Class Method Details

.delete(item) ⇒ Object

Deletes a lock unless it has ttl

This is good for situations when a job is locked by another item

Parameters:

  • item (Hash)

    a Sidekiq job hash



29
30
31
32
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 29

def delete(item)
  SidekiqUniqueJobs::Job.add_digest(item)
  SidekiqUniqueJobs::Locksmith.new(item).delete
end

.delete!(item) ⇒ Object

Deletes a lock regardless of if it was locked or has ttl.

This is good for situations when a job is locked by another item

Parameters:

  • item (Hash)

    a Sidekiq job hash



38
39
40
41
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 38

def delete!(item)
  SidekiqUniqueJobs::Job.add_digest(item)
  SidekiqUniqueJobs::Locksmith.new(item).delete!
end

.unlock(item) ⇒ Object

Unlocks a job.

Parameters:

  • item (Hash)

    a Sidekiq job hash



13
14
15
16
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 13

def unlock(item)
  SidekiqUniqueJobs::Job.add_digest(item)
  SidekiqUniqueJobs::Locksmith.new(item).unlock
end

.unlock!(item) ⇒ Object

Unlocks a job.

Parameters:

  • item (Hash)

    a Sidekiq job hash



20
21
22
23
# File 'lib/sidekiq_unique_jobs/unlockable.rb', line 20

def unlock!(item)
  SidekiqUniqueJobs::Job.add_digest(item)
  SidekiqUniqueJobs::Locksmith.new(item).unlock!
end