Class: Sidekiq::SortedSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sidekiq/api.rb

Direct Known Subclasses

JobSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ SortedSet

Returns a new instance of SortedSet.



543
544
545
546
# File 'lib/sidekiq/api.rb', line 543

def initialize(name)
  @name = name
  @_size = size
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



541
542
543
# File 'lib/sidekiq/api.rb', line 541

def name
  @name
end

Instance Method Details

#clearObject Also known as: 💣



563
564
565
566
567
# File 'lib/sidekiq/api.rb', line 563

def clear
  Sidekiq.redis do |conn|
    conn.del(name)
  end
end

#scan(match, count = 100) ⇒ Object



552
553
554
555
556
557
558
559
560
561
# File 'lib/sidekiq/api.rb', line 552

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

#sizeObject



548
549
550
# File 'lib/sidekiq/api.rb', line 548

def size
  Sidekiq.redis { |c| c.zcard(name) }
end