Method: Redlock::Client#lock!

Defined in:
lib/redlock/client.rb

#lock!(*args) ⇒ Object

Locks a resource, executing the received block only after successfully acquiring the lock, and returning its return value as a result. See Redlock::Client#lock for parameters.



65
66
67
68
69
70
71
72
# File 'lib/redlock/client.rb', line 65

def lock!(*args)
  fail 'No block passed' unless block_given?

  lock(*args) do |lock_info|
    raise LockError, 'failed to acquire lock' unless lock_info
    return yield
  end
end