Search code examples
ruby-on-rails-4resque

Rails and Resque - How to ignore jobs if they are too old


I am using Rails and Resque to perform some background jobs. The jobs that are enqueued I need them to be completed within a given time interval, lets say 10 seconds. If the worker doesn't start a given job in 10 seconds then I don't want it - the end user will request it again in that case.

When I enqueue a job I guess I could add a timestamp, and when the job is taken I could check if we are within the limit and perform the tasks, otherwise return.

I wonder if there is any other way to accomplish this, "out-of-the-box".


Solution

  • Well, I guess I did answer my own question. I have added a timestamp when I enqueue the job, when the worker takes it I check if it is within 10 seconds and start performing.