Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pmatsinopoulos/e40e2265cbfa65f4b20c577310c604a6 to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/e40e2265cbfa65f4b20c577310c604a6 to your computer and use it in GitHub Desktop.
5 Sidekiq Jobs Using #increment
user = User.find_by!(email: "[email protected]")
puts "Initial user_balance: #{user.user_balance.balance}"
5.times do
CalculateUserBalanceJob.perform_later(user.id)
end
sleep(60) # just wait for the background job to finish. This is long enough
# for all the 5 Sidekiq jobs to finish
user.reload
puts "user_balance: #{user.user_balance.balance}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment