title: Async redis & promise
body: <p>I have a scenario where I have to run a loop and each iteration call redis set function (async) and then I have to close the connection to redis.  </p>
  
  <p>Sequence...</p>
  
  <ol>
  <li>Run the foreach loop.  </li>
  <li>For each element use the redis set command.  </li>
  <li>When loop is completed, close the redis connection.  </li>
  </ol>
  
  <p>Now redis connection is getting closed before all the set operation is completed inside the for loop. </p>
  
  <hr>
  
  <p>Additional detail...</p>
  
  <ul>
  <li>I'm using the <a href="https://github.com/NodeRedis/node_redis#clientbatchcommands" rel="nofollow noreferrer">node.js redis client</a>.  </li>
  <li>I know why this happening but I'm not sure how to resolve this situation.  </li>
  <li>I'm new newbie in NodeJS.  </li>
  </ul>