Method: Sidekiq::SortedSet#scan

Defined in:
lib/sidekiq/api.rb

#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=“redis.io/commands/scan/”>SCAN documentation</a> for implementation details.

Parameters:

  • match (String)

    a snippet or regexp to filter matches.

  • count (Integer) (defaults to: 100)

    number of elements to retrieve at a time, default 100

Yield Parameters:



683
684
685
686
687
688
689
690
691
692
# File 'lib/sidekiq/api.rb', line 683

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