0
我使用node_redis庫
https://github.com/NodeRedis/node_redis
有關於如何使用SINTERSTORE/SUNIONSTORE和ZINTERSTORE/ZUNIONSTORE給出的例子非常少,有關於如何傳遞參數在客戶端這些功能沒有例子。如何從Node.js的redis客戶端使用SINTERSTORE和ZINTERSTORE?
我使用node_redis庫
https://github.com/NodeRedis/node_redis
有關於如何使用SINTERSTORE/SUNIONSTORE和ZINTERSTORE/ZUNIONSTORE給出的例子非常少,有關於如何傳遞參數在客戶端這些功能沒有例子。如何從Node.js的redis客戶端使用SINTERSTORE和ZINTERSTORE?
我嘗試和找到正確的方式做到這一點
var redis=require('redis');
var client=redis.createClient();
client.on('connect',function() {
console.log('connected');
});
client.sadd('sa', 'a');
client.sadd('sa', 'b');
client.sadd('sa', 'c');
client.sadd('sb', 'b');
client.sadd('sb', 'c');
client.sadd('sb', 'd');
client.SINTER(['sa', 'sb'], function (err, intersection) {
console.log(intersection[0]+" "+intersection[1]);
});
client.ZINTERSTORE('sc','2','sa', 'sb', function (err, intersection) {
console.log(intersection);
});
client.ZRANGEBYSCORE('sc','-inf','inf',function (err,reply) {
console.log(reply);
});
只需提供在Redis的文檔中給出的順序輸入