我有一个代码
var redis = require("redis"), client = redis.createClient(6379, '192.168.1.48');
client.on("error", function (err) {
console.log("Error " + err);
});
client.sadd("hoang","post:1");
client.sadd("hoang","post:2");
client.sadd("hoang","post:3");
client.sadd("hoang","post:4");
client.sadd("hoang","post:5");
client.sadd("hoang","post:7");
client.sadd("lan","post:1");
client.sadd("lan","post:2");
client.sadd("lan","post:3");
client.sadd("lan","post:4");
client.sadd("lan","post:5");
client.sadd("lan","post:6");
var arr = client.sinter("hoang","lan");
console.log(arr.length);
和控制台打印
未定义
如何从redis命令中获取数组。
答案 0 :(得分:0)
我认为client.sinter
不返回值,需要回调函数,如:
client.sinter(["hoang","lan"], function(err, res){
console.log(res, res.length);
})
如果您需要更多信息,请提供您正在使用的redis客户端的链接。