var redis = require("redis"); var client = redis.createClient(); js = { "like":"macdn", "hate":"kfc" }; //client.set("foo_rand000000000000", "some fantastic value2"); client.set("foo_rand000000000000", JSON.stringify(js)); client.get("foo_rand000000000000", function (err, reply) { console.log(reply.toString()); }); client.get("dislike", function (err, reply) { if (err) console.log(err); else console.log(reply.toString()); client.end(); }); console.log ('eee');
var redis = require("redis"); var client = redis.createClient(); client.get("foo_rand000000000000", function (err, reply) { console.log(reply); js = JSON.parse(reply); console.log( js.like ); console.log( js.hate ); client.end(); }); console.log ('eee');
ref:
http://stackoverflow.com/questions/8986982/how-should-i-store-json-in-redis
http://stackoverflow.com/questions/5729891/redis-performance-store-json-object-as-a-string