Blog地址:http://www.flakor.cn/2014-03-17-274.html
// redis 链接
var redis = require('redis');
var client = redis.createClient('6379', '127.0.0.1');
// redis 链接错误
client.on("error", function(error) {
console.log(error);
});
// redis 验证 (reids.conf未开启验证,此项可不需要)
client.auth("2222");
client.select('15', function(error){
if(error) {
console.log(error);
} else {
// set
client.set('str_key_0', '0', function(error, res) {
if(error) {
console.log(error);
} else {
console.log(res);
}
// 关闭链接
client.end();
});
}
});