SINTERSTORE

将多个集合的交集存储在一个键中。

语法

SINTERSTORE destination key [key ...]

引入版本:1.0.0

复杂度摘要:O(N*M)

[!NOTE] 此命令的行为在集群 Redis 环境中有所不同。请参阅 多键操作 页面了解更多信息。

该命令等于 SINTER,但不返回结果集,而是存储在 destination 中。

如果 destination 已存在,则将其覆盖。

必需参数

destination

存储结果集的键。

key [key ...]

设置一个或多个相交关键点。

示例

redis> SADD key1 "a"
(integer) 1
redis> SADD key1 "b"
(integer) 1
redis> SADD key1 "c"
(integer) 1
redis> SADD key2 "c"
(integer) 1
redis> SADD key2 "d"
(integer) 1
redis> SADD key2 "e"
(integer) 1
redis> SINTERSTORE key key1 key2
(integer) 1
redis> SMEMBERS key
1) "c"

Redis Software 与 Redis Cloud 兼容性

Redis
软件
Redis
Cloud
说明
✅ 标准
✅ 主动-主动
✅ 标准
✅ 主动-主动

返回值

RESP2

整数回复:结果集中的元素数量。

RESP3

整数回复:结果集中的元素数量。

参见

SINTER | SINTERCARD

资料来源:Redis 官方 SINTERSTORE 文档;中文内容参考 Redis 文档许可。