当前位置:网站首页>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边栏推荐
- 浅谈线程池相关配置
- Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
- Use usedeferredvalue for asynchronous rendering
- Systemserver service and servicemanager service analysis
- 2022 low voltage electrician test question simulation test question bank simulation test platform operation
- GB/T-2423. XX environmental test documents, including the latest documents
- 小米青年工程师,本来只是去打个酱油
- Query word weight, search word weight calculation
- Summary of some experiences in the process of R & D platform splitting
- [punch in questions] integrated daily 5-question sharing (phase II)
猜你喜欢

結婚後

Batch detect whether there is CDN in URL - high accuracy
![[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)

Force deduction daily question 540 A single element in an ordered array

Feature query of hypergraph iserver rest Service

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

Which kind of sports headphones is easier to use? The most recommended sports headphones

Cache processing scheme in high concurrency scenario

el-table的render-header用法

Start a business
随机推荐
旋转框目标检测mmrotate v0.3.1 学习模型
How to create an instance of the control defined in SAP ui5 XML view at runtime?
es面试题
【做题打卡】集成每日5题分享(第二期)
Après le mariage
小米青年工程师,本来只是去打个酱油
MongoDB非关系型数据库
Connected block template and variants (4 questions in total)
Batch detect whether there is CDN in URL - high accuracy
query词权重, 搜索词权重计算
JVM interview
What are the common proxy servers and what are the differences?
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度
Face++ realizes face detection in the way of flow
QT使用sqllite
[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)
About DNS
批量检测url是否存在cdn—高准确率
设置状态栏颜色