This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Tobias Lütke (author)
Sat Mar 08 10:32:56 -0800 2008
locking /
| name | age | message | |
|---|---|---|---|
| |
README | Sat Mar 08 10:32:56 -0800 2008 | [Tobias Lütke] |
| |
init.rb | Wed Mar 05 15:17:24 -0800 2008 | [Tobias Lütke] |
| |
lib/ | Sat Mar 08 10:32:56 -0800 2008 | [Tobias Lütke] |
README
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! } }'



