title: How to get all data from Redis to JSON
body: <p>I would like to retrieve all data from Redis (database '10') into a JSON variable. But I'm a bit confused with asynchronous call... I've tried this:</p>
  
  <pre><code>redis = require('redis');
  client = redis.createClient();
  client.send_command('select', [10], redis.print);
  var r = {};
  client.keys('*', function (err, keys) {
      keys.forEach(function(c){       
          client.get(c, function(err, v){     
              r[c] = v;                           
          });     
      });
  });
  console.log(JSON.stringify(r));
  client.quit();
  </code></pre>
  
  <p>But my 'r' JSON variable is empty... How can I do it using callback methods, or synchronous code?</p>
  
  <p>Thanks.</p>