lib/redlocker/lock.rb
# Acquires the specified lock or raises a `Redlocker::TimeoutError` when
# the lock can not be acquired within the specified `timeout`. Uses the
# specified `delay` to poll redis and check whether or not the lock is
# free.  When the lock has been successfully acquired, it gets refreshed
# every second, i.e. its expiry value of 5 seconds is refreshed within
# redis every second.
#
# @param block [Proc] The block which should be executed when the lock is
#   acquired.
Acquires the specified lock or raises a `Redlocker::TimeoutError` when
the lock can not be acquired within the specified `timeout`. Uses the
specified `delay` to poll redis and check whether or not the lock is
free.  When the lock has been successfully acquired, it gets refreshed
every second, i.e. its expiry value of 5 seconds is refreshed within
redis every second.
Acquires the specified lock or raises a ` Redlocker :: TimeoutError ` when the lock can not be acquired within the specified ` timeout ` . Uses the specified ` delay ` to poll redis and check whether or not the lock is free . When the lock has been successfully acquired it gets refreshed every second i . e . its expiry value of 5 seconds is refreshed within redis every second .
def acquire(&block)
      raise(TimeoutError, "Did not get lock #{name} within #{timeout} seconds") unless acquire_lock
      begin
        keep_lock(&block)
      ensure
        release_lock
      end
    end
def acquire ( & block ) raise ( TimeoutError , "Did not get lock #{name} within #{timeout} seconds" ) unless acquire_lock begin keep_lock ( & block ) ensure release_lock end end
Acquires the specified lock or raises a `Redlocker::TimeoutError` when
the lock can not be acquired within the specified `timeout`.
Acquires the specified lock or raises a ` Redlocker :: TimeoutError ` when the lock can not be acquired within the specified ` timeout ` .
block
The block which should be executed when the lock is acquired.
The block which should be executed when the lock is acquired .