Skip to content

Instantly share code, notes, and snippets.

@elainenaomi
Forked from flaviokr/sidekiq_api_reference.rb
Created January 3, 2018 18:40
Show Gist options
  • Save elainenaomi/505101388e8e3ed4db7a8a0c24b636ba to your computer and use it in GitHub Desktop.
Save elainenaomi/505101388e8e3ed4db7a8a0c24b636ba to your computer and use it in GitHub Desktop.
Sidekiq API Reference
Sidekiq.redis { |conn| conn.flushdb } # clear everything
Sidekiq::Queue.all # get all queues
Sidekiq::Queue.new # get the "default" queue
Sidekiq::Queue.new("mailer") # get the "mailer" queue
Sidekiq::Queue.new.clear # deletes all jobs in a queue, by removing the queue
Sidekiq::Queue.all.each(&:clear) # deletes all jobs in all queues
ss = Sidekiq::ScheduledSet.new
ss.size
ss.clear
jobs = ss.select { |job| job.klass == 'SomeWorker' }
jobs.each(&:delete)
Sidekiq::RetrySet.new
Sidekiq::DeadSet.new
Sidekiq::ProcessSet.new # running processes
Sidekiq::Stats.new.reset # reset statistics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment