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
-
#as_json(options = nil) ⇒ Object
private
:nodoc:.
-
#clear ⇒ Boolean
(also: #💣)
Always true.
-
#initialize(name) ⇒ SortedSet
constructor
private
:nodoc:.
-
#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.
Constructor Details
#initialize(name) ⇒ SortedSet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
:nodoc:
680 681 682 683 |
# File 'lib/sidekiq/api.rb', line 680 def initialize(name) @name = name @_size = size end |
Instance Attribute Details
#Name ⇒ Object (readonly)
Redis key of the set
676 |
# File 'lib/sidekiq/api.rb', line 676 attr_reader :name |
#name ⇒ Object (readonly)
Redis key of the set
676 677 678 |
# File 'lib/sidekiq/api.rb', line 676 def name @name end |
Instance Method Details
#as_json(options = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
:nodoc:
718 719 720 |
# File 'lib/sidekiq/api.rb', line 718 def as_json( = nil) {name: name} # 5336 end |
#clear ⇒ Boolean Also known as: 💣
Returns always true.
708 709 710 711 712 713 |
# File 'lib/sidekiq/api.rb', line 708 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 SCAN documentation for implementation details.
696 697 698 699 700 701 702 703 704 705 |
# File 'lib/sidekiq/api.rb', line 696 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 |