【问题标题】:Delete Sidekiq jobs with a particular argument?删除带有特定参数的 Sidekiq 作业?
【发布时间】:2021-01-22 09:16:20
【问题描述】:

假设我在某个时候加入了一个看起来像这样的工作:

HardWorker.perform(command_id, user_id)

有什么方法可以删除所有与特定 command_id 关联的作业(从 Redis 队列中)?

【问题讨论】:

    标签: ruby-on-rails redis sidekiq


    【解决方案1】:
    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-02
      • 2021-01-21
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 2015-10-03
      • 2017-07-29
      相关资源
      最近更新 更多