Helo家伙我只是nodejs和redis的新手,但我不知道使用nodejs / express在redis中插入数据。你能帮助我或给我一个例子吗?谢谢:*
~janella:)
答案 0 :(得分:2)
您可以使用最受欢迎(至少目前为止)的客户端模块:redis
示例(来自文档)
var redis = require("redis"),
client = redis.createClient();
// if you'd like to select database 3, instead of 0 (default), call
// client.select(3, function() { /* ... */ });
client.on("error", function (err) {
console.log("Error " + err);
});
client.set("string key", "string val", redis.print);
client.hset("hash key", "hashtest 1", "some value", redis.print);
client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
client.hkeys("hash key", function (err, replies) {
console.log(replies.length + " replies:");
replies.forEach(function (reply, i) {
console.log(" " + i + ": " + reply);
});
client.quit();
});