当前位置:网站首页>[summary of interview questions] zj6 redis
[summary of interview questions] zj6 redis
2022-06-24 02:59:00 【Hello y】
redis Common commands
What are various data types commonly used for
String: Can be used for caching 、 Distributed Session
Hash: Can be used to store user information 、 User home page visits 、 Combination query
(hash Better for storing objects , Store an object in hash Type will take up less memory , And easy access to the entire object .)
hmset myhash field1 value1 field2 value2: Set up multiple field
List: Timeline list of Weibo followers , Simple queue
Set: Fabulous 、 Step on 、 Friend relationship ( You can find intersection union difference sets )
Zset: Ranking List
exists key Judge whether it exists key
expire key 10 10s Be overdue
redis General Command
Redis Operation command summary
redis Save a decimal 1.5 How to add one
incrbyfloat Add or subtract floating point numbers
Be careful :incr Is integer increment
redis If it exists, operate the command
set key value Just insert when it doesn't exist , exist iju Modify .
Be careful :
setnx key value If it does not exist, perform the operation , There is no operation
setex key time value Set expiration time (expire)
redis Message queue of list aggregate , How do producers and consumers know if there is any news inside
Redis Of List The main operations of are lpush/lpop/rpush/rpop Four kinds of , From the head and from the tail push/pop, besides List There are also two pop Blocking version of the operation blpop/brpop, Used to block getting an object (list When there is no data hi Blocked ).
Redis It is usually used as a message server to handle background work or message tasks . A simple queue mode : The producer puts the message into a list , Consumers waiting for news use rpop command ( By polling ), Or use brpop To get the news .
In order to prevent data loss and inconsistency ( That is, the consumer just took out the message and collapsed , Message not processed ), use rpoplpush command : Not only does it return a message, it also adds the message to another backup list , If everything goes well , After the client finishes processing the message , use rem Delete the corresponding message from this sub table . If it fails, the message will be bounced back from the backup table to the original queue rpoplpush
Java Jedis operation Redis Example ( Two )——list producer / The consumer pattern implements message queuing
边栏推荐
- 11111dasfada and I grew the problem hot hot I hot vasser shares
- How to strengthen prison security measures? Technologies you can't imagine
- South Korea's national network is disconnected. Who launched the network "attack"?
- Wkwebview audio and video media playback processing
- Ner's past, present and future Overview - past
- Production line motor monitoring and maintenance - application case of 5g edge calculation for paperboard line motor maintenance
- Build a reliable, scalable and maintainable application system
- 2022-2028 global aircraft audio control panel system industry research and trend analysis report
- File access methods on Fortress server how to log in to the server
- [51nod] 3047 displacement operation
猜你喜欢
![[51nod] 2102 or minus and](/img/68/0d966b0322ac1517dd2800234d386d.jpg)
[51nod] 2102 or minus and

2022-2028 global cell-based seafood industry research and trend analysis report
![[51nod] 3216 Awards](/img/94/fdb32434d1343040d711c76568b281.jpg)
[51nod] 3216 Awards

2022-2028 global portable two-way radio equipment industry research and trend analysis report

2022-2028 global aircraft audio control panel system industry research and trend analysis report

2022-2028 global medical coating materials industry research and trend analysis report

Permission maintenance topic: domain controller permission maintenance

The cost of on-site development of software talent outsourcing is higher than that of software project outsourcing. Why

2022-2028 global medical modified polypropylene industry research and trend analysis report
![[51nod] 2653 section XOR](/img/2d/cb4bf4e14939ce432cac6d35b6a41b.jpg)
[51nod] 2653 section XOR
随机推荐
How to use nsfilemanager
2022-2028 global medical coating materials industry research and trend analysis report
[51nod] 2106 an odd number times
[51nod] 3216 Awards
Why can't cloud games connect to the server? What if the cloud game fails to connect to the server?
2022-2028 Global Industry Survey and trend analysis report on portable pressure monitors for wards
System design: File Hosting Service
Opengl: how to use shader to convert RGBA to nv21 image format? (open source for the first time in the whole network)
What is etcd and its application scenarios
Cloud call: one line of code is directly connected to wechat open interface capability
[Tencent cloud] how can the MySQL database on the cloud fully back up the data base script?
What are the configuration requirements for cloud desktop servers? What are the main characteristics of the three points?
Easycvr cannot be played when cascaded to the superior platform. Troubleshooting
Is the server connected to the fortress machine a virtual machine? What if the fortress machine IP is not connected
Data acquisition and transmission instrument environmental pollution monitoring of iron and steel plant
South Korea's national network is disconnected. Who launched the network "attack"?
Release of the first batch of bay area group standards! Tencent security takes the lead in developing trusted digital identity standards
Solution to session problem of missing laravel jump page
The most comprehensive arrangement of safe operation solutions from various manufacturers
How to access the cloud game management server? Which cloud game management server can I choose?
