Last active
February 16, 2016 23:34
-
-
Save x0bandeira/b58c6f340d12df5850ca to your computer and use it in GitHub Desktop.
While using resque-scheduler 2.0.1, you have to delete scheduled jobs by hand
This file contains 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
def remove_scheduled_resque_job(&block) | |
[].tap do |processed| | |
$redis.scan_each(match: "resque:delayed:*") do |key| | |
$redis.lrange(key, 0, -1).each do |value| | |
begin | |
payload = ActiveSupport::JSON.decode(value) | |
if yield(payload) | |
$redis.lrem(key, 1, value) | |
processed << value | |
end | |
rescue => e | |
raise e, "error processing key: #{key}" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment