sunionstore
1. 基本語法
sunionstore(destination
, key
, [key,...]
, callback
)
destination
, key
, [key,...]
, callback
) 功能類似sunion,主要差別在sunion直接回傳聯集成員;而sunionstore將聯集成員儲存到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.sunionstore('union','user:1:choice', 'user:2:choice', redis.print);
client.smembers('union', redis.print);
Reply: 5
Reply: C,B,A,D,E
Last updated
Was this helpful?