class SidekiqUniqueJobs::Key
Key
class wraps logic dealing with various lock keys
@author Mikael Henriksson <mikael@mhenrixon.com>
Attributes
@!attribute [r] changelog
@return [String] the zset with changelog entries
@!attribute [r] digest
@return [String] the digest key for which keys are created
@!attribute [r] digests
@return [String] the zset with locked digests
@!attribute [r] expiring_digests
@return [String] the zset with locked expiring_digests
@!attribute [r] info
@return [String] information about the lock
@!attribute [r] locked
@return [String] the hash key with locked job_id's
@!attribute [r] primed
@return [String] the list key with primed job_id's
@!attribute [r] queued
@return [String] the list key with queued job_id's
Public Class Methods
Source
# File lib/sidekiq_unique_jobs/key.rb, line 46 def initialize(digest) @digest = digest @queued = suffixed_key("QUEUED") @primed = suffixed_key("PRIMED") @locked = suffixed_key("LOCKED") @info = suffixed_key("INFO") @changelog = CHANGELOGS @digests = DIGESTS @expiring_digests = EXPIRING_DIGESTS end
Initialize a new Key
@param [String] digest the digest to use as key
Public Instance Methods
Source
# File lib/sidekiq_unique_jobs/key.rb, line 79 def ==(other) digest == other.digest end
Compares keys by digest
@param [Key] other the key to compare with
@return [true, false]
Source
# File lib/sidekiq_unique_jobs/key.rb, line 88 def to_a [digest, queued, primed, locked, info, changelog, digests, expiring_digests] end
Returns all keys as an ordered array
@return [Array] an ordered array with all keys
Source
# File lib/sidekiq_unique_jobs/key.rb, line 63 def to_s digest end
Provides the only important information about this keys
@return [String]
Private Instance Methods
Source
# File lib/sidekiq_unique_jobs/key.rb, line 94 def suffixed_key(variable) "#{digest}:#{variable}" end