Reputation: 4930
Is there a way to use Redis to retrieve the following job count?
Sidekiq::ScheduledSet.new.inject(0) do |memo, job|
memo += 1 if job.at <= Time.now
memo
end
I.e. jobs that are scheduled, should have been run already, but weren't. This works ok for smaller queue sizes but scales poorly for bigger ones (30+ seconds for 60k scheduled jobs). Thanks!
Upvotes: 0
Views: 833
Reputation: 4930
Inspired by Mike, I went with the following approach:
Sidekiq.redis { |c| c.zcount('schedule', '-inf', Time.now.to_f) }
Upvotes: 1
Reputation: 22208
"ZRANGEBYSCORE schedule '-inf' #{Time.now.to_f}"
https://redis.io/commands/zrangebyscore
Upvotes: 1