Created
October 15, 2015 14:10
-
-
Save spalenza/68bd0b4690a00ca32d19 to your computer and use it in GitHub Desktop.
Remove Resque jobs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference | |
# http://stackoverflow.com/questions/10274974/how-can-i-delete-specific-jobs-from-resque-queue-without-clearing-the-whole-queu | |
# Removes a job from a queue. Expects a string queue name, a | |
# string class name, and, optionally, args. | |
# | |
# Returns the number of jobs destroyed. | |
# | |
# If no args are provided, it will remove all jobs of the class | |
# provided. | |
# | |
# That is, for these two jobs: | |
# | |
# { 'class' => 'UpdateGraph', 'args' => ['defunkt'] } | |
# { 'class' => 'UpdateGraph', 'args' => ['mojombo'] } | |
# | |
# The following call will remove both: | |
# | |
# Resque::Job.destroy(queue, 'UpdateGraph') | |
# | |
# Whereas specifying args will only remove the 2nd job: | |
# | |
# Resque::Job.destroy(queue, 'UpdateGraph', 'mojombo') | |
# | |
# 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. | |
def self.destroy(queue, klass, *args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment