Skip to content

Instantly share code, notes, and snippets.

@jhonoryza
Last active January 9, 2024 11:36
Show Gist options
  • Save jhonoryza/7e898df26738a580f2e409a3eca38ccc to your computer and use it in GitHub Desktop.
Save jhonoryza/7e898df26738a580f2e409a3eca38ccc to your computer and use it in GitHub Desktop.
handling race condition

atomic lock

  • usefull if you have multiple worker and you want to proses job with only one worker
  • or you can use for update transaction in database without using database lock

behind the scene if you use database for cache driver laravel will create 2 table to store the lock

database lock

this one use database lock feature

https://laravel.com/docs/10.x/queries#pessimistic-locking

explanation lock in mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment