node_redis可让你在Node.js编程环境中连接并操作Redis上的数据。
示例代码:
varredis=require("redis"),client=redis.createClient();client.on("error",function(err){console.log("Error"+err);});client.set("stringkey","stringval",redis.print);client.hset("hashkey","hashtest1","somevalue",redis.print);client.hset(["hashkey","hashtest2","someothervalue"],redis.print);client.hkeys("hashkey",function(err,replies){console.log(replies.length+"replies:");replies.forEach(function(reply,i){console.log(""+i+":"+reply);});client.quit();});
评论