当前位置:网站首页>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) 3
2. 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
边栏推荐
- Connected block template and variants (4 questions in total)
- Kibana操控ES
- 2022-2028 global encryption software industry research and trend analysis report
- Yyds dry goods inventory accelerating vacuum in PG
- 2022-2028 global aluminum beverage can coating industry research and trend analysis report
- How to turn off the LED light of Rog motherboard
- Es interview questions
- LFM信号加噪、时频分析、滤波
- Unit · elementary C # learning notes
- How to run oddish successfully from 0?
猜你喜欢
[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
Which kind of sports headphones is easier to use? The most recommended sports headphones
Vsocde has cli every time it is opened js
Redis cluster
Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
[opencv] - comprehensive examples of five image filters
Mmsegmentation series training and reasoning their own data set (3)
LFM signal denoising, time-frequency analysis, filtering
随机推荐
高并发场景下缓存处理方案
[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
多线程查询,效率翻倍
Mongodb non relational database
【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)
Mmsegmentation series training and reasoning their own data set (3)
What are the characteristics of common web proxy IP
设置状态栏颜色
2022-2028 global encryption software industry research and trend analysis report
Systemserver service and servicemanager service analysis
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
How to develop digital collections? How to develop your own digital collections
Which kind of sports headphones is easier to use? The most recommended sports headphones
[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)
Missing numbers from 0 to n-1 (simple difficulty)
How does proxy IP participate in the direct battle between web crawlers and anti crawlers
Force deduction daily question 540 A single element in an ordered array
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
Unit · elementary C # learning notes
Cache processing scheme in high concurrency scenario