Redis 中的 SUNIONSTORE 命令函数

首页 / Redis入门教程 / Redis 中的 SUNIONSTORE 命令函数

Redis SUNIONSTORE 命令用于存储所有给定集合的并集产生的集合元素。不存在的键被认为是空集。

SUNIONSTORE - 返回值

返回整数,输出集中的元素数量。

SUNIONSTORE - 语法

以下是Redis SUNIONSTORE 命令的基本语法。

redis 127.0.0.1:6379> SUNIONSTORE DESTINATION KEY KEY1..KEYN

SUNIONSTORE - 例

redis 127.0.0.1:6379> SADD myset1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> SADD myset1 "Learnfk" 
(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) "Learnfk" 
3) "hello" 
4) "foo"

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

技术与商业案例解读 -〔徐飞〕

许式伟的架构课 -〔许式伟〕

深入浅出计算机组成原理 -〔徐文浩〕

Spring Boot与Kubernetes云原生微服务实践 -〔杨波〕

物联网开发实战 -〔郭朝斌〕

etcd实战课 -〔唐聪〕

如何成为学习高手 -〔高冷冷〕

云原生架构与GitOps实战 -〔王炜〕

AI绘画核心技术与实战 -〔南柯〕

好记忆不如烂笔头。留下您的足迹吧 :)