Class: Sidekiq::SortedSet
- Inherits:
-
Object
- Object
- Sidekiq::SortedSet
- Includes:
- Enumerable
- Defined in:
- lib/sidekiq/api.rb
Overview
Base class for all sorted sets within Sidekiq.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Redis key of the set.
-
#Name ⇒ Object
readonly
Redis key of the set.
Instance Method Summary collapse
-
#clear ⇒ Boolean
(also: #π£)
Always true.
-
#scan(match, count = 100) {|each| ... } ⇒ Object
Scan through each element of the sorted set, yielding each to the supplied block.
-
#size ⇒ Object
real-time size of the set, will change.
Instance Attribute Details
#name ⇒ Object (readonly)
Redis key of the set
585 586 587 |
# File 'lib/sidekiq/api.rb', line 585 def name @name end |
#Name ⇒ Object (readonly)
Redis key of the set
585 |
# File 'lib/sidekiq/api.rb', line 585 attr_reader :name |
Instance Method Details
#clear ⇒ Boolean Also known as: π£
Returns always true.
617 618 619 620 621 622 |
# File 'lib/sidekiq/api.rb', line 617 def clear Sidekiq.redis do |conn| conn.unlink(name) end true end |
#scan(match, count = 100) {|each| ... } ⇒ Object
Scan through each element of the sorted set, yielding each to the supplied block. Please see Redis's <a href=βSCANβ>redis.io/commands/scan/β>SCAN documentation</a> for implementation details.
605 606 607 608 609 610 611 612 613 614 |
# File 'lib/sidekiq/api.rb', line 605 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(name, match: match, count: count) do |entry, score| yield SortedEntry.new(self, score, entry) end end end |
#size ⇒ Object
real-time size of the set, will change
595 596 597 |
# File 'lib/sidekiq/api.rb', line 595 def size Sidekiq.redis { |c| c.zcard(name) } end |