Class: SidekiqUniqueJobs::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/key.rb

Overview

Key class wraps logic dealing with various lock keys

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(digest) ⇒ Key

Initialize a new Key

Parameters:

  • digest (String)

    the digest to use as key



46
47
48
49
50
51
52
53
54
55
# 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

Instance Attribute Details

#changelogObject (readonly)

Returns the value of attribute changelog.



31
32
33
# File 'lib/sidekiq_unique_jobs/key.rb', line 31

def changelog
  @changelog
end

#digestObject (readonly)

Returns the value of attribute digest.



11
12
13
# File 'lib/sidekiq_unique_jobs/key.rb', line 11

def digest
  @digest
end

#digestsObject (readonly)

Returns the value of attribute digests.



35
36
37
# File 'lib/sidekiq_unique_jobs/key.rb', line 35

def digests
  @digests
end

#expiring_digestsObject (readonly)

Returns the value of attribute expiring_digests.



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

def expiring_digests
  @expiring_digests
end

#infoObject (readonly)

Returns the value of attribute info.



27
28
29
# File 'lib/sidekiq_unique_jobs/key.rb', line 27

def info
  @info
end

#lockedObject (readonly)

Returns the value of attribute locked.



23
24
25
# File 'lib/sidekiq_unique_jobs/key.rb', line 23

def locked
  @locked
end

#primedObject (readonly)

Returns the value of attribute primed.



19
20
21
# File 'lib/sidekiq_unique_jobs/key.rb', line 19

def primed
  @primed
end

#queuedObject (readonly)

Returns the value of attribute queued.



15
16
17
# File 'lib/sidekiq_unique_jobs/key.rb', line 15

def queued
  @queued
end

Instance Method Details

#==(other) ⇒ true, false

Compares keys by digest

Parameters:

  • other (Key)

    the key to compare with

Returns:

  • (true, false)


79
80
81
# File 'lib/sidekiq_unique_jobs/key.rb', line 79

def ==(other)
  digest == other.digest
end

#inspectObject

See Also:



68
69
70
# File 'lib/sidekiq_unique_jobs/key.rb', line 68

def inspect
  digest
end

#to_aArray

Returns all keys as an ordered array

Returns:

  • (Array)

    an ordered array with all keys



88
89
90
# File 'lib/sidekiq_unique_jobs/key.rb', line 88

def to_a
  [digest, queued, primed, locked, info, changelog, digests, expiring_digests]
end

#to_sString

Provides the only important information about this keys

Returns:

  • (String)


63
64
65
# File 'lib/sidekiq_unique_jobs/key.rb', line 63

def to_s
  digest
end