Method: Sidekiq::JobSet#fetch
- Defined in:
- lib/sidekiq/api.rb
#fetch(score, jid = nil) ⇒ Array<SortedEntry>
Fetch jobs that match a given time or Range. Job ID is an optional second argument.
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
# File 'lib/sidekiq/api.rb', line 786 def fetch(score, jid = nil) begin_score, end_score = if score.is_a?(Range) [score.first, score.last] else [score, score] end elements = Sidekiq.redis { |conn| conn.zrange(name, begin_score, end_score, "BYSCORE", "withscores") } elements.each_with_object([]) do |element, result| data, job_score = element entry = SortedEntry.new(self, job_score, data) result << entry if jid.nil? || entry.jid == jid end end |