Class: Sidekiq::SortedSet
- Inherits:
-
Object
- Object
- Sidekiq::SortedSet
- Includes:
- Enumerable
- Defined in:
- lib/sidekiq/api.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #clear ⇒ Object (also: #💣)
-
#initialize(name) ⇒ SortedSet
constructor
A new instance of SortedSet.
- #scan(match, count = 100) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(name) ⇒ SortedSet
Returns a new instance of SortedSet.
560 561 562 563 |
# File 'lib/sidekiq/api.rb', line 560 def initialize(name) @name = name @_size = size end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
558 559 560 |
# File 'lib/sidekiq/api.rb', line 558 def name @name end |
Instance Method Details
#clear ⇒ Object Also known as: 💣
580 581 582 583 584 |
# File 'lib/sidekiq/api.rb', line 580 def clear Sidekiq.redis do |conn| conn.unlink(name) end end |
#scan(match, count = 100) ⇒ Object
569 570 571 572 573 574 575 576 577 578 |
# File 'lib/sidekiq/api.rb', line 569 def scan(match, count = 100) return to_enum(:scan, match, count) unless block_given? match = "*#{match}*" unless match.include?("*") Sidekiq.redis do |conn| conn.zscan_each(name, match: match, count: count) do |entry, score| yield SortedEntry.new(self, score, entry) end end end |
#size ⇒ Object
565 566 567 |
# File 'lib/sidekiq/api.rb', line 565 def size Sidekiq.redis { |c| c.zcard(name) } end |