当前位置:网站首页>[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
边栏推荐
- Face recognition using cidetector
- What are the configuration requirements for cloud desktop servers? What are the main characteristics of the three points?
- Cloud call: one line of code is directly connected to wechat open interface capability
- How to understand EDI requirements of trading partners
- The 2021 Tencent digital ecology conference is coming
- 14. Tencent cloud IOT device side learning - data template application development
- Tencent Youtu won the champion of iccv2021 LVIs challenge workshop and the best innovation award of the project
- How to strengthen prison security measures? Technologies you can't imagine
- 2022-2028 global cell-based seafood industry research and trend analysis report
- [51nod] 3047 displacement operation
猜你喜欢
![[51nod] 3047 displacement operation](/img/cb/9380337adbc09c54a5b984cab7d3b8.jpg)
[51nod] 3047 displacement operation

2022-2028 global genome editing mutation detection kit industry survey and trend analysis report
![[51nod] 2102 or minus and](/img/68/0d966b0322ac1517dd2800234d386d.jpg)
[51nod] 2102 or minus and

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

2022-2028 global medical modified polypropylene industry research and trend analysis report

2022-2028 global anti counterfeiting label industry research and trend analysis report

2022-2028 global aircraft front wheel steering system industry research and trend analysis report

2022-2028 global third-party data platform industry research and trend analysis report

IOS development - multithreading - thread safety (3)

2022-2028 global marine wet exhaust hose industry research and trend analysis report
随机推荐
Where is the cloud game server? Can individuals rent cloud game servers?
Easycvr cannot be played when cascaded to the superior platform. Troubleshooting
Buddha's foot before examination: the second play of leetcode
DB2 database generates HTML patrol Report
CPS November additional incentive rules
How to install the cloud desktop security server certificate? What can cloud desktops do?
IOS development - multithreading - thread safety (3)
Flink practice tutorial: getting started 1- zero basic users realize simple Flink tasks
Storage crash MySQL database recovery case
What is etcd and its application scenarios
Ner's past, present and future Overview - past
LeetCode 599. Minimum index sum of two lists
How to bind EIP to access public network in tke cluster fixed IP mode pod
C common regular expression collation
Build a reliable, scalable and maintainable application system
Objective-C downloads pictures from the network, saves them, and displays them from the save with uiimageview
Compile blender source code
The server size of the cloud desktop. The cloud desktop faces the server configuration requirements
Wkwebview audio and video media playback processing
Mutual conversion between qstring and qdatetime
