当前位置:网站首页>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边栏推荐
- C write TXT file
- Batch detect whether there is CDN in URL - high accuracy
- Baohong industry | what misunderstandings should we pay attention to when diversifying investment
- [pit] how to understand "parameter fishing"
- What is the difference between an intermediate human resource manager and an intermediate economist (human resources direction)?
- Formatting logic of SAP ui5 currency amount display
- Remote connection to MySQL under windows and Linux system
- Learning notes of software testing -- theoretical knowledge of software testing
- 2022-2028 global encryption software industry research and trend analysis report
- tarjan2
猜你喜欢

How to create an instance of the control defined in SAP ui5 XML view at runtime?

Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved

Analysis of FLV packaging format

What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
![[JVM] detailed description of the process of creating objects](/img/6e/0803b6b63c48337985faae8d5cbe1a.png)
[JVM] detailed description of the process of creating objects

About DNS

Baohong industry | four basic knowledge necessary for personal finance

Formatting logic of SAP ui5 currency amount display

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

创业了...
随机推荐
使用 useDeferredValue 进行异步渲染
QT使用sqllite
Pat a-1165 block reversing (25 points)
Query word weight, search word weight calculation
[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)
Kibana操控ES
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
[learn C and fly] day 5 chapter 2 program in C language (Exercise 2)
Set status bar color
Mathematics in Sinorgchem: computational geometry
2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
Baohong industry | 6 financial management models at different stages of life
【无标题】
Oracle creates a user with read-only permission in four simple steps
Yyds dry goods inventory accelerating vacuum in PG
QT implementation interface jump
Systemserver service and servicemanager service analysis
es面试题
Websocket + spingboot realize code scanning login
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)