假设我在某个时间点排队了一个工作,它看起来像这样:
HardWorker.perform(command_id, user_id)
我能否以某种方式删除所有具有特定 command_id
的作业(从 Redis 队列中)?
假设我在某个时间点排队了一个工作,它看起来像这样:
HardWorker.perform(command_id, user_id)
我能否以某种方式删除所有具有特定 command_id
的作业(从 Redis 队列中)?
command_id = 'command id to delete'
queue = Sidekiq::Queue.new('the_queue_name')
queue.each do |job|
if job.klass == 'HardWorker' && job.args.first == command_id
job.delete
end
end