Delete specific jobs from a Resque queue

This is a handy little piece of code in case you have jobs of a certain type that you want deleted from your Resque queues. The Resque.destroy method allows you to define the queue to clean up and the class name of the job type you want removed.

The following call will remove all jobs of class UpdateGraph:

Resque::Job.destroy(queue, 'UpdateGraph')

You can also specify arguments to filter out certain jobs of that type:

Resque::Job.destroy(queue, 'UpdateGraph', 'foo')

Keep in mind the performance of this function is not fast:

This method can be potentially very slow and memory intensive, depending on the size of your queue, as it loads all jobs into a Ruby array before processing.