[英]How to insert data in Redis using NodeJs?
Helo guys i'm just new in nodejs and redis but i don't have any idea on inserting data in redis using nodejs/express. Helo 伙计们,我只是 nodejs 和 redis 的新手,但我不知道如何使用 nodejs/express 在 redis 中插入数据。 Can you please help me or provide me an example?你能帮我或给我举个例子吗? Thanks谢谢
You can use the most popular (at least for now) client module: redis您可以使用最流行的(至少目前)客户端模块: redis
Example (from documentation)示例(来自文档)
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();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.