title: Finding number of users online/offline with redis,nodejs
body: <p>I am using socket.io, redis for tracking users online/offline status. Here I am storing the no.of users with name as key with the pattern hub_id. I am able to get the number of users by just getting count of keys matching hub_ pattern. Now the key has value as status online or offline. </p>
  
  <p>I am unable to get the no. users online or offline variable outside the for loop. </p>
  
  <pre><code>  app.get('/test', function(req, res) {
    client.keys('hub*', function (err, keys) {
      console.log(keys.length);
      for (var i=0; i&lt;keys.length; i++){
      client.hgetall(keys[i], function(err, reply) {
      if(reply.status == "online"){
        onlinehub++;
      }
      else if(reply.status == "offline"){
        offlinehub++;
      }
    });
    }
      console.log(onlinehub +"-" +offlinehub)
  
      });
  });
  </code></pre>