Pro Expiring Jobs

Mike Perham edited this page Feb 2, 2017 · 1 revision

Sidekiq Pro supports jobs which expire after a certain length of time.

Jobs that are set to expire can run as long as they want, but an expiring job must start executing before the expiration time.

Use Cases

  1. Perhaps you want to expire a cache which has a TTL of 30 minutes with a Sidekiq job. If the job doesn't process successfully within 30 minutes, there's no point in continuing to execute the job.
  2. You use a Sidekiq job to send a daily digest email. If the job doesn't execute within 24 hours, perhaps you want to skip that day as the user might only care about the latest digest.


Require the feature in your initializer:

require 'sidekiq/pro/expiry'

Defining Expiration


class SomeWorker
  include Sidekiq::Worker
  sidekiq_options expires_in: 1.hour

Dynamically, per job:


expires_in must be a relative time, not an absolute timestamp.

Expiration knows about scheduled jobs: schedule a job to run two hours from now with a one hour expiration and it will expire three hours from now.


If a job expires and was part of a batch, the job result counts as a success and the batch will count as succeeded.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.