lib/ohm/locking.rb
# Lock the object so no other instances can modify it.
# This method implements the design pattern for locks
# described at: http://code.google.com/p/redis/wiki/SetnxCommand
#
# @see Model#mutex
Lock the object so no other instances can modify it.
Lock the object so no other instances can modify it .
def lock!(wait = 0.1)
      until redis.call("SETNX", key[:_lock], lock_timeout) == 1
        next unless lock = redis.call("GET", key[:_lock])
        sleep(wait) and next unless lock_expired?(lock)
        break unless lock = redis.call("GETSET", key[:_lock], lock_timeout)
        break if lock_expired?(lock)
      end
    end
def lock! ( wait = 0.1 ) until redis . call ( "SETNX" , key [ :_lock ] , lock_timeout ) == 1 next unless lock = redis . call ( "GET" , key [ :_lock ] ) sleep ( wait ) and next unless lock_expired? ( lock ) break unless lock = redis . call ( "GETSET" , key [ :_lock ] , lock_timeout ) break if lock_expired? ( lock ) end end
Lock the object so no other instances can modify it.
Lock the object so no other instances can modify it .
wait
<not_specific>
see
None