当前位置:网站首页>【Redis】Set类型
【Redis】Set类型
2022-06-29 01:56:00 【骑着蜗牛ひ追导弹'】
一、Set类型
Redis中的Set类型与java中的HashSet类似,可以看做是一个value为null的HashMap,具备和HashMap相类似的特征:
- 无序
- 元素不可以重复
- 查找快
- 支持交集、并集、差集等功能

基本的通用命令如上图所示,下面进行详细介绍!
1.1 SADD & SREM & SCARD

SADD key member …:向set中添加一个或多个元素
SREM key member …:移除set中的指定元素
SCARD key:返回set中元素的个数

1.2 SISMEMBER & SMEMBERS

- SISMEMBER key member:判断一个元素是否存在与set中
- SMEMBERS key :获取set中所有的元素

1.3 SINTER & SDIFF & SUNION
SINTER key1 key2 …:求key1与key2的交集

SDIFF key1 key2 …:求key1与key2的差集

SUNION key1 key2 …:求key1和key2的并集

案例:将下列数据用Redis的Set集合来存储:·张三的好友有:李四、王五、赵六;李四的好友有:王五、麻子、二狗利用Set的命令实现下列功能:

- 计算张三的好友有几人

- 计算张三和李四有哪些共同好友

- 查询哪些人是张三的好友却不是李四的好友

- 查询张三和李四的好友总共有哪些人

- 判断李四是否是张三的好友

- 判断张三是否是李四的好友

- 将李四从张三的好友列表中移除

边栏推荐
- I want to buy stocks today, OK? Is it safe to open an account online now?
- Analysis of parsing principle of OData metadata request response in SAP ui5 application
- Would like to ask how to choose a securities firm? Is it safe to open an account online now?
- [image detection] recognition of the front and back of a coin based on texture features with matlab code attached
- Test a CSDN free download software
- Research on VB multi-layer firewall technology - state detection
- 如何成为一名高级数字 IC 设计工程师(6-7)数字 IC 验证篇:DEBUG 技巧
- Fundamentals of scala (3): operators and process control
- 微信运动自动点赞
- The metadata request parsing principle of OData XML format applied by SAP ui5 is based on domparser
猜你喜欢

SAP ui5 beginner tutorial 24 - how to use OData data model

Exclusive analysis | real situation of software test about resume and interview

Large scale visual relationship understanding

Oculusrifts and unity UI interaction (1) - Overview

Flex application: realize two rows and five columns of data, self-adaptive

I have summarized some experiences from the whole process of R & D platform splitting
Fundamentals of scala (3): operators and process control

In MySQL database, the two data written when creating tables with foreign keys are the same. Do I copy them or fail to display them
![[image detection] recognition of the front and back of a coin based on texture features with matlab code attached](/img/61/1fb15e9defa1fc471c4d2d34cc1ed4.jpg)
[image detection] recognition of the front and back of a coin based on texture features with matlab code attached

Installation de la base de données Oracle dans docker
随机推荐
如何成为一名高级数字 IC 设计工程师(5-1)理论篇:时钟技术、复位技术
Docker中安装Oracle数据库
Niuke.com Huawei question bank (41~50)
I have summarized some experiences from the whole process of R & D platform splitting
一种全面屏手势适配方案
Near's storage stacking
Magic Quadrant of motianlun's 2021 China Database
A full screen gesture adaptation scheme
Brief description of 802.1x Protocol
Installing Oracle database in docker
What is stock online account opening? Is it safe to open an account online?
RISC CPU design based on FPGA (4) 36 questions about the project and their answers
如何成为一名高级数字 IC 设计工程师(3-5)工具篇:SpyGlass 技术
Qt基础教程:QStringList
[机缘参悟-33]:眼见不一定为实,大多数时候“眼见为虚”
Utiliser kubernets Resource Lock pour compléter son application ha
P7 Erkai early know - registration and application creation
IPFs Brief
Would like to ask how to choose a securities firm? Is it safe to open an account online now?
芯片原厂必学技术(1)引言