当前位置:网站首页>Redis set command line operation (intersection, union and difference, random reading, etc.)
Redis set command line operation (intersection, union and difference, random reading, etc.)
2022-07-02 02:55:00 【Procedural ape (siege lion)】
Here to redis Of set Simple demonstration of how to use the command , It is helpful to understand the meaning and usage of relevant commands . Actual business scenarios should be combined redis The interface provided by the client performs relevant operations .
1. Add one set The order of sadd
127.0.0.1:6379> sadd setA 1 2 3
(integer) 3
127.0.0.1:6379> sadd setB 2 3 4
(integer) 32. Calculate two set The difference between the set
127.0.0.1:6379> sdiff setA setB
1) "1"
127.0.0.1:6379> sdiff setB setA
1) "4"3. Calculate two set Intersection
127.0.0.1:6379> sinter setA setB
1) "2"
2) "3"4. utilize set Realize random lottery
127.0.0.1:6379> SADD order 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
(integer) 10
127.0.0.1:6379> SMEMBERS order
1) "1001"
2) "1002"
3) "1003"
4) "1004"
5) "1005"
6) "1006"
7) "1007"
8) "1008"
9) "1009"
10) "1010"
127.0.0.1:6379> SPOP order 3
1) "1001"
2) "1003"
3) "1006"
127.0.0.1:6379> SPOP order 2
1) "1004"
2) "1002"
127.0.0.1:6379> SPOP order 1
1) "1007"Add data to the set , Then view the data list in the collection , Random sampling 3 individual 、2 And 1 Data .
5. Like the model
127.0.0.1:6379> SADD like:1 1001 1002 1003 1004 1005
(integer) 5
# Delete attention
127.0.0.1:6379> SREM like:1 1002
(integer) 1
# Judge whether to pay attention to
127.0.0.1:6379> SISMEMBER like:1 1002
(integer) 0
127.0.0.1:6379> SISMEMBER like:1 1005
(integer) 1
# Check out the following list
127.0.0.1:6379> SMEMBERS like:1
1) "1001"
2) "1003"
3) "1004"
4) "1005"
# Check the number of followers
127.0.0.1:6379> SCARD like:1
(integer) 4边栏推荐
- Which kind of sports headphones is easier to use? The most recommended sports headphones
- [pit] how to understand "parameter fishing"
- Discussion on related configuration of thread pool
- MongoDB非关系型数据库
- Mmsegmentation series training and reasoning their own data set (3)
- [learn C and fly] day 5 chapter 2 program in C language (Exercise 2)
- Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
- Baohong industry | four basic knowledge necessary for personal finance
- Kibana controls es
- Share the basic knowledge of a common Hongmeng application
猜你喜欢

Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science

Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
![[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)](/img/39/42b1726e5f446f126a42d7ac673dce.png)
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)

Baohong industry | what misunderstandings should we pay attention to when diversifying investment

创业了...
![寻找重复数[抽象二分/快慢指针/二进制枚举]](/img/9b/3c001c3b86ca3f8622daa7f7687cdb.png)
寻找重复数[抽象二分/快慢指针/二进制枚举]

2022-2028 global nano abrasive industry research and trend analysis report

只需简单几步 - 开始玩耍微信小程序

LFM信号加噪、时频分析、滤波

Vsocde has cli every time it is opened js
随机推荐
Questions d'entrevue
Basic 01: print string
Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
Use usedeferredvalue for asynchronous rendering
批量检测url是否存在cdn—高准确率
Use the open source project [banner] to achieve the effect of rotating pictures (with dots)
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
Mongodb non relational database
MMSegmentation系列之训练与推理自己的数据集(三)
Analysis of FLV packaging format
Addition without addition, subtraction, multiplication and division (simple difficulty)
Connected block template and variants (4 questions in total)
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
Pat a-1165 block reversing (25 points)
buu_ re_ crackMe
V-model of custom component
Principle of computer composition - interview questions for postgraduate entrance examination (review outline, key points and reference)
MongoDB非关系型数据库
GB/T-2423.xx 环境试验文件,整理包括了最新的文件里面
Redis cluster