Cancel all enqueued regular jobs

Using the Jobs class is it possible to cancel all enqueued regular jobs.

For example if I do Jobs.enqueue(:some_job, some_param: 1) is it possible later in my code to do cancel them. Something like Jobs.cancel_enqueued(:some_job, some_param: 1)

What I am trying to solve is that I have a Jobs.enqueue in active record callback but sometimes they are piling and I would like to cancel the existing one before creating the new one.

1 Like