lib/master_lock/redis_lock.rb
def acquire(timeout:)
      timeout_time = Time.now + timeout
      loop do
        locked = redis.set(redis_key, owner, nx: true, px: ttl_ms)
        return true if locked
        return false if Time.now >= timeout_time
        sleep(@sleep_interval)
      end
    end
# Attempt to acquire the lock. If the lock is already held, this will
# attempt multiple times to acquire the lock until the timeout period is up.
#
# @param [Fixnum] how long to wait to acquire the lock before failing
# @return [Boolean] whether the lock was acquired successfully
Attempt to acquire the lock. If the lock is already held, this will
attempt multiple times to acquire the lock until the timeout period is up.
Attempt to acquire the lock . If the lock is already held this will attempt multiple times to acquire the lock until the timeout period is up .
def acquire(timeout:)
      timeout_time = Time.now + timeout
      loop do
        locked = redis.set(redis_key, owner, nx: true, px: ttl_ms)
        return true if locked
        return false if Time.now >= timeout_time
        sleep(@sleep_interval)
      end
    end
def acquire ( timeout : ) timeout_time = Time . now + timeout loop do locked = redis . set ( redis_key , owner , nx : true , px : ttl_ms ) return true if locked return false if Time . now >= timeout_time sleep ( @sleep_interval ) end end
Attempt to acquire the lock.
Attempt to acquire the lock .
whether the lock was acquired successfully
whether the lock was acquired successfully
Boolean
timeout
None