簡體   English   中英

你如何從Node.js中的redis客戶端使用SINTERSTORE和ZINTERSTORE?

[英]How do you use SINTERSTORE and ZINTERSTORE from a redis client in Node.js?

我正在使用node_redis庫
https://github.com/NodeRedis/node_redis
關於如何使用SINTERSTORE / SUNIONSTORE和ZINTERSTORE / ZUNIONSTORE的示例非常少,沒有關於如何在客戶端中傳遞這些函數的參數的示例。

我試過並找到了正確的方法

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文檔中給出的順序提供輸入

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM