sdiffstore

1. 基本語法

sdiffstore(destination, key , [key,...], callback)

功能類似sdiff,主要差別在sdiff直接回傳差集成員;而sdiffstore差集成員儲存到destination集合中,並回傳差集的成員「數量」。

2. 範例

const arr1 = ['A', 'B', 'C'];
const arr2 = ['C', 'D', 'E'];

client.sadd('user:1:choice', arr1);
client.sadd('user:2:choice', arr2);

client.sdiffstore('diff','user:1:choice', 'user:2:choice', redis.print);
client.smembers('diff', redis.print);
Reply: 2
Reply: A,B

Last updated

Was this helpful?