title: Redis WATCH MULTI EXEC by one client
body: <p>I am using NodeJS + Express + Redis on RedisOnGo + node_redis as a client. I expect a lot of concurrency, so trying to test WATCH. This example won't contain Express, just necessary stuff.</p>
  
  <pre><code>var redis = require("redis")
  var rc = redis.createClient(config.redis.port, config.redis.host)
  
  rc.auth(config.redis.hash, function(err) {
      if (err) {
          throw err
      }
  })
  
  rc.on('ready', function () {
      rc.set("inc",0)
      for(var i=1;i&lt;=10;i++){
          rc.watch("inc")
          rc.get("inc",function(err,data){
              var multi = rc.multi()
              data++ // I do know I can use rc.incr(), this is just for example
              multi.set("inc",data)
              multi.exec(function(err,replies){
                  console.log(replies)
              })
          })
      }
  })
  </code></pre>
  
  <p><strong>Expecting result</strong>: getting N errors in exec callbacks and finally getting "inc" variable = 10-N.</p>
  
  <p><strong>Unexpected result</strong>: getting 0 errors in exec callbacks but finally getting "inc" variable = 1.</p>
  
  <p>Watch doesn't work with my code.</p>
  
  <p>I have found this thread <a href="https://stackoverflow.com/questions/11832637/redis-and-watch-multi-allows-concurrent-users">redis and watch + multi allows concurrent users</a>. They say it is because of the only redis client.</p>
  
  <p>Then I found this thread <a href="https://stackoverflow.com/questions/11009880/should-i-create-a-new-redis-client-for-each-connection">Should I create a new Redis client for each connection?</a>. They say that generating a new client for each transaction "is definitely not recommended". I am lost.</p>
  
  <p>Please also note, that I have to authenticate to Redis server. Thanks in advance!</p>
  
  <p><strong>EDITION 1:</strong></p>
  
  <p>I was able to make it work using local Redis instance (so I do not use client.auth) by creating a new client connection before each WATCH-MULTI-EXEC iteration. Not sure if it is good though, but results now are 100% accurate.</p>
  
  <p><strong>EDITION 2</strong>
  Made it work if I create a new client connection before each WATCH-MULTI-EXEC iteration and then do client.auth and wait for client.on.</p>
  
  <p>The question still exists, is it OK that I create new client connections for each iteration?</p>