When reading the Sidekiq Wiki I see the following examples:
From Getting started:
Send a message to be processed asynchronously:
HardWorker.perform_async('bob', 5)
You can also send messages by calling the delay method on a class method:
User.delay.do_some_stuff(current_user.id, 20)
Also, from Delayed extensions:
Use delay to deliver your emails asynchronously. Use delay_for(interval) or delay_until(time) to deliver the email at some point in the future.
UserMailer.delay.welcome_email(@user.id) UserMailer.delay_for(5.days).find_more_friends_email(@user.id) UserMailer.delay_until(5.days.from_now).find_more_friends_email(@user.id)
So what is actually the difference between perfrom_async
and delay
? In which situations would I prefer the one over the other?
perform_async is Sidekiq's native API. delay is a compatibility API with DelayedJob. Use perform_async when possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With