当前位置:网站首页>Redis basic type - combined with set
Redis basic type - combined with set
2022-07-24 06:47:00 【Life goes on and battles go on】
aggregate Set: More than one value Value
#====================================
# sadd Put one or Multiple member elements are added to the collection , Can't repeat
# smembers Returns all members of a collection
# sismember Command to determine whether a member element is a member of a collection
#====================================
127.0.0.1:6379> sadd myset wyt
(integer) 1
127.0.0.1:6379> sadd myset lmp
(integer) 1
127.0.0.1:6379> sadd myset lmp
(integer) 0
127.0.0.1:6379> smembers myset
1) "wyt"
2) "lmp"
127.0.0.1:6379> sismember myset hyd
(integer) 0
127.0.0.1:6379> sismember myset wyt
(integer) 1
#====================================
# scard : Get the number of elements in the collection
#====================================
127.0.0.1:6379> scard myset
(integer) 2
#====================================
# srem key value : Used to remove one or more member elements from a collection
#====================================
127.0.0.1:6379> srem myset wyt
(integer) 1
127.0.0.1:6379> smembers myset
1) "lmp"
#====================================
# srandmember key : The command returns a random element in the collection
#====================================
127.0.0.1:6379> smembers myset
1) "hyd"
2) "lmp"
3) "yjy"
4) "syy"
5) "wyt"
6) "gqy"
127.0.0.1:6379> srandmember myset
"syy"
127.0.0.1:6379> srandmember myset 2
1) "lmp"
2) "gqy"
127.0.0.1:6379> srandmember myset 2
1) "wyt"
2) "yjy"
#====================================
# spop key : Used to remove the specified key One or more random elements of
#====================================
127.0.0.1:6379> smembers myset
1) "lmp"
2) "hyd"
3) "syy"
4) "yjy"
5) "wyt"
6) "gqy"
127.0.0.1:6379> spop myset
"gqy"
127.0.0.1:6379> spop myset
"syy"
127.0.0.1:6379> spop myset
"wyt"
127.0.0.1:6379> smembers myset
1) "lmp"
2) "hyd"
3) "yjy"
#====================================
# smove source destination member
# Members will be specified member Elements from source The assembly moves to destination aggregate
#====================================
127.0.0.1:6379> sadd myset wyt
(integer) 1
127.0.0.1:6379> sadd myset lmp
(integer) 1
127.0.0.1:6379> sadd myset hyd
(integer) 1
127.0.0.1:6379> sadd myset yjy
(integer) 1
127.0.0.1:6379> sadd myset syy
(integer) 1
127.0.0.1:6379> sadd myset gqy
(integer) 1
127.0.0.1:6379> smembers myset
1) "hyd"
2) "lmp"
3) "yjy"
4) "syy"
5) "wyt"
6) "gqy"
127.0.0.1:6379> smembers myset1
1) "hyd"
2) "lmp"#====================================
- Number set class
- Difference set :sdiff- intersection :sinter
- Combine :sunion
#====================================
127.0.0.1:6379> sadd key1 a
(integer) 1
127.0.0.1:6379> sadd key1 b
(integer) 1
127.0.0.1:6379> sadd key1 c
(integer) 1
127.0.0.1:6379> sadd key2 c
(integer) 1
127.0.0.1:6379> sadd key2 d
(integer) 1
127.0.0.1:6379> sadd key2 e
(integer) 1
127.0.0.1:6379> sdiff key1 key2
1) "a"
2) "b"
127.0.0.1:6379> sinter key1 key2
1) "c"
127.0.0.1:6379> sunion key1 key2
1) "b"
2) "a"
3) "d"
4) "e"
5) "c"
边栏推荐
- 创建WPF项目
- Jmeter分布式压测
- MySQL batch modifies the data table code and character set to utf8mb4
- LM393 电压比较器及其典型电路介绍
- 【LVGL布局】柔性布局
- 【媒体控制器】开源项目学习笔记(基于Arduino Micro开发板)
- Install agent and proxy using custom ZABBIX package (version 4.0.5)
- kubernetes 的Deployment(部署),Service概念,动态扩缩容
- sojson jsjiami.com.v6 爬虫js逆向
- Visibility:hidden and display:none
猜你喜欢

System safety and Application

Jenkins CI CD

【LVGL(3)】设置对象大小、位置、盒子模型、状态

Redis入门

Special effects - click the mouse and the randomly set text will appear

创建WPF项目

基于回归分析的广告投入销售额预测——K邻近,决策树,随机森林,线性回归,岭回归

Redis.conf详解

Special effects - click with the mouse and the fireworks will burst

Account and authority management
随机推荐
Special effects - when the mouse moves, there will be a custom expression trail
Special effects - click the mouse, and a random color of love will appear
kubernetes简介和架构及其原理
STM32基于 FatFs R0.14b&SD Card 的MP3音乐播放器(也算是FatFs的简单应用了吧)
【LVGL(6)】显示中文设置,制作中文字库
Introduction to kubernetes (kubernetes benefits)
Introduction, architecture and principle of kubernetes
Identification of Chinese medicinal materials
Redis入门
Experiment: disk quota operation
【LVGL(1)】LVGL的简单介绍
深入了解MySQL 两把锁啥时候用(表锁,行锁)
JS - calculate the side length and angle of a right triangle
Use of awk
实验:磁盘配额操作
It's not too much to fight a landlord in idea!
Special effects - starry cosmic background effects
object-oriented
Redis基本类型-有序集合Zset
STM32 MP3 music player based on FatFs r0.14b & SD card (also a simple application of FatFs)