Redis参考手册
Redis Sunionstore 命令
Redis Sunionstore 命令
Redis Sunionstore 命令
Redis 集合(Set)
Redis Sunionstore 命令将给定集合的并集存储在指定的集合 destination 中。如果 destination 已经存在,则将其覆盖。
语法
redis Sunionstore 命令基本语法如下:
redis 127.0.0.1:6379> SUNIONSTORE DESTINATION KEY KEY1..KEYN
可用版本
>= 1.0.0
返回值
结果集中的元素数量。
实例
redis 127.0.0.1:6379> SADD myset1 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "world" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "bar" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "bar" (integer) 1 redis 127.0.0.1:6379> SUNIONSTORE myset myset1 myset2 (integer) 1 redis 127.0.0.1:6379> SMEMBERS myset 1) "bar" 2) "world" 3) "hello" 4) "foo"
Redis 集合(Set)
Redis Sunionstore 命令 |
---|
Redis 是一个开源的使用 ANSI C 语言编写、遵守 BSD 协议、支持网络、可基于内存亦可持久化的日志型、Key-Value 数据库,并提供多种语言的 API。 它通常被称为数据结构服务器,因为值( value )可以是 字符串( String ), 哈希(Map),列表(list),集合( sets ) 和 有序集合( sorted sets )等类型。
主页 | https://redis.io/ |
源码 | https://github.com/antirez/redis |
发布版本 | 4.0.2 |