Skip to content

Instantly share code, notes, and snippets.

@x0bandeira
Last active February 16, 2016 23:34
Show Gist options
  • Save x0bandeira/b58c6f340d12df5850ca to your computer and use it in GitHub Desktop.
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
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