Express +Redis

$ npm install redis --save
var redis = require('redis'),
    client = redis.createClient();

client.on("error", function (err) {
    console.log("Error " + err);
});

client.set('obj01',JSON.stringify({
    name : 'Diana',
    sex  : 'female',
    age  : 16,
    love : {
        name : 'King',
        age  : 16,
        sex  : 'male',
        love : {
            name : 'Diana',
            sex  : 'female',
            age  : 16
        }
    }
}),function (err,hmseted) {
    console.log('err:%j---hmseted:%j',err,hmseted);
});

client.get('obj01',function (err,hmgeted) {
    console.log('err:%j---hmgeted:',err,JSON.parse(hmgeted));
});

console log:
err:null---hmgeted: 
{ 
  name: 'Diana',
  sex: 'female',
  age: 16,
  love: 
   { name: 'King',
     age: 16,
     sex: 'male',
     love: { name: 'Diana', sex: 'female', age: 16 } 
    }
 }

你可能感兴趣的:(Express +Redis)