Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Spelling 101: it's acquire not aquire

  • Loading branch information...
commit 835469ed48f4c2de95856fe2f221eaa624b267a2 1 parent ef1e994
@tobi authored
Showing with 10 additions and 10 deletions.
  1. +4 −4 README
  2. +6 −6 lib/locking.rb
View
8 README
@@ -1,9 +1,9 @@
Locking
=======
-Very simple plugin which adds the aquire_lock method to active record base. This is mysql only.
+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 aquire the same lock.
+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.
@@ -11,7 +11,7 @@ for redundancy reasons.
Example
=======
-Invoice.aquire_lock("Shopify billing") do
+Invoice.acquire_lock("Shopify billing") do
Invoice.find_all_due.each { |invoice| invoice.collect_payment! }
@@ -23,4 +23,4 @@ Usecase
# save to run on several machines at the same time:
- ./script/runner 'Invoice.aquire_lock("Shopify billing") { Invoice.find_all_due.each { |invoice| invoice.collect_payment! } }'
+ ./script/runner 'Invoice.acquire_lock("Shopify billing") { Invoice.find_all_due.each { |invoice| invoice.collect_payment! } }'
View
12 lib/locking.rb
@@ -11,8 +11,8 @@ def self.included(base)
module ClassMethods
- # Aquires an application level lock in the mysql server.
- def aquire_lock(lock_name = table_name, wait_timeout = 0)
+ # acquires an application level lock in the mysql server.
+ def acquire_lock(lock_name = table_name, wait_timeout = 0)
case c = connection.select_value("SELECT GET_LOCK(#{quote_value(lock_name)}, #{quote_value(wait_timeout)})")
when '1'
yield if block_given?
@@ -28,10 +28,10 @@ def aquire_lock(lock_name = table_name, wait_timeout = 0)
connection.select_one("SELECT RELEASE_LOCK(#{quote_value(lock_name)})")
end
- # Aquires an application level lock in the mysql server. Throws Locking::LockTimeout if the
- # lock cannot be aquired.
- def aquire_lock!(lock_name = table_name, wait_timeout = 0, &block)
- aquire_lock(lock_name, table_name, &block) or raise LockTimeout, 'Timeout waiting for lock'
+ # acquires an application level lock in the mysql server. Throws Locking::LockTimeout if the
+ # lock cannot be acquired.
+ def acquire_lock!(lock_name = table_name, wait_timeout = 0, &block)
+ acquire_lock(lock_name, table_name, &block) or raise LockTimeout, 'Timeout waiting for lock'
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.