Skip to content

Instantly share code, notes, and snippets.

@sclinede
Last active August 29, 2015 14:14
Show Gist options
  • Save sclinede/8affb4ffa6713e7113f8 to your computer and use it in GitHub Desktop.
Save sclinede/8affb4ffa6713e7113f8 to your computer and use it in GitHub Desktop.
Clear BgExecutor queue by job name
bgkey = ::BgExecutor::Configuration[:redis][:namespace] + ':bg_executor:jobs_queue'
job_name = 'worker:mail' # 'map_coord'
# Test:
result = []
($redis.llen bgkey).times { |idx| p idx if idx % 100 == 0; val = ($redis.lindex bgkey, idx).to_s; result << val if val.include?(job_name) }
# And Run:
# result.each { |val| $redis.lrem bgkey, 0, val }
# NOT ($redis.llen bgkey).times { |idx| val = ($redis.lindex bgkey, idx); $redis.lrem bgkey, 0, val if val.include?(job_name) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment