ZDIFFSTORE

语法
ZDIFFSTORE destination numkeys key [key ...]
可用版本
Redis 开源版 6.2.0
时间复杂度
最坏情况下为 O(L + (N-K)log(N)),其中 L 是所有集合中的元素总数,N 是第一个集合的大小,K 是结果集合的大小。
ACL 类别
@write, @sortedset, @slow,

计算第一个有序集合与所有后续输入有序集合之间的差集,并将结果存储在 destination 中。输入键的总数由 numkeys 指定。

不存在的键被视为空集合。

如果 destination 已经存在,它将被覆盖。

示例

ZADD zset1 1 "one" ZADD zset1 2 "two" ZADD zset1 3 "three" ZADD zset2 1 "one" ZADD zset2 2 "two" ZDIFFSTORE out 2 zset1 zset2 ZRANGE out 0 -1 WITHSCORES

RESP2/RESP3 回复

整数回复:结果有序集合 destination 中的成员数量。
评价此页
返回顶部 ↑