lib/distributed_mutex.rb
# Use lua script to maintain atomicity
Use lua script to maintain atomicity
Use lua script to maintain atomicity
def extend_lock(extend_time)
    extend_lua = %(
      if (redis.call('get', KEYS[1]) == ARGV[1])
      then
        return redis.call('expire', KEYS[1], tonumber(ARGV[2]))
      else
        return 0
      end
    )
    redis.eval(extend_lua, keys: [key], argv: [uuid, extend_time]).positive?
  end
def extend_lock ( extend_time ) extend_lua = %(
      if (redis.call('get', KEYS[1]) == ARGV[1])
      then
        return redis.call('expire', KEYS[1], tonumber(ARGV[2]))
      else
        return 0
      end
    ) redis . eval ( extend_lua , keys : [ key ] , argv : [ uuid , extend_time ] ) . positive? end
Use lua script to maintain atomicity
Use lua script to maintain atomicity
extend_time