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"

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

技术教程推荐

AI技术内参 -〔洪亮劼〕

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

图解 Google V8 -〔李兵〕

Selenium自动化测试实战 -〔郭宏志〕

高楼的性能工程实战课 -〔高楼〕

说透芯片 -〔邵巍〕

讲好故事 -〔涵柏〕

程序员的测试课 -〔郑晔〕

如何讲好一堂课 -〔薛雨〕

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