-1

Helo 伙计们,我只是 nodejs 和 redis 的新手,但我对使用 nodejs/express 在 redis 中插入数据一无所知。你能帮我或给我一个例子吗?谢谢 :*

~珍妮拉 :)

4

1 回答 1

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();
});
于 2013-08-26T10:39:22.540 回答