-
Notifications
You must be signed in to change notification settings - Fork 2
Global named locks (req. mysql) -- Extraction from Shopify
tobi/locking
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Locking ======= Very simple plugin which adds the acquire_lock method to active record base. This is mysql only. As long as a lock of a certain name is acquired no other connection on the server is able to acquire the same lock. This is very useful for background tasks such as billing or search server re-indexing which would cause errors when they would be ran from multiple machines at the same time but you still want to run them from multiple machines at the same time for redundancy reasons. Example ======= Invoice.acquire_lock("Shopify billing") do Invoice.find_all_due.each { |invoice| invoice.collect_payment! } end Usecase ======= # save to run on several machines at the same time: ./script/runner 'Invoice.acquire_lock("Shopify billing") { Invoice.find_all_due.each { |invoice| invoice.collect_payment! } }'
About
Global named locks (req. mysql) -- Extraction from Shopify
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published