当前位置:网站首页>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
边栏推荐
- MongoDB非关系型数据库
- Render header usage of El table
- New programmer magazine | Li Penghui talks about open source cloud native message flow system
- C # use system data. The split mixed mode assembly is generated for the "v2.0.50727" version of the runtime, and it cannot be loaded in the 4.0 runtime without configuring other information
- Connected block template and variants (4 questions in total)
- Mmsegmentation series training and reasoning their own data set (3)
- LeetCode刷题(十)——顺序刷题46至50
- Baohong industry | 6 financial management models at different stages of life
- [Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials
- 【JVM】创建对象的流程详解
猜你喜欢
buu_ re_ crackMe
Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
[staff] pitch representation (bass clef | C1 36 note pitch representation | C2 48 note pitch representation | C3 60 note pitch representation)
2022-2028 global deep sea generator controller industry research and trend analysis report
[JVM] detailed description of the process of creating objects
Pychart creates new projects & loads faster & fonts larger & changes appearance
Start a business
浅谈线程池相关配置
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)
随机推荐
After marriage
[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)
2022安全员-C证考试题及模拟考试
Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
buu_ re_ crackMe
Questions d'entrevue
Stack - es - official documents - filter search results
What are the common proxy servers and what are the differences?
Redis cluster
Remote connection to MySQL under windows and Linux system
The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
GB/T-2423.xx 环境试验文件,整理包括了最新的文件里面
超图iServer rest服务之feature查询
Mongodb base de données non relationnelle
Use usedeferredvalue for asynchronous rendering
MongoDB非关系型数据库
[opencv] - comprehensive examples of five image filters
【JVM】创建对象的流程详解
QT使用sqllite
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding