title: Cannot get valid list while using redis with node.js
body: <p>I am working with <strong>node.js</strong> and using <strong>redis</strong> for caching some of the data on the server.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>var client = redis.createClient();
  client.on("error", function (err) {
      console.log("Error " + err);
  });
  
  client.flushall();
  
  function redis_get(key){
      client.get(key, function(err, value) {
          if (err) {
          console.error("error");
          } else {
              return value;
          }
      });
  }
  
  function redis_set(key, value){
      client.set(key, JSON.stringify(value), function(err) {
          if (err) {
              console.error("error");
          }
      return true
      });
  }
  
  function main(){
  
      var new_items = [{"id": 1, "name": "abc"}, {"id": 2, "name": "xyz"}, {"id": 3, "name": "bbc"}];
  
      //set data in redis
      redis_set("key", new_items);
  
      //get data from redis
      var redis_items = redis_get("key");
  }
  </code></pre>
  
  <p><strong>Summary of code:</strong></p>
  
  <p>The main function is called, which further calls 2 other functions (redis_set or redis_get). Redis_set takes a key and a value pair whereas redis_get takes the key which points to the data.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>The set works perfectly but the problem is with <strong>GET</strong>. I am not getting my data in the way I had set it in redis. I have used JASON.parse() in get as I have stringify the data when i had set it.</p>