当前位置:网站首页>Redis review summary
Redis review summary
2022-07-28 20:32:00 【Lunar Yin shortage】
Redis
Redis What can you do with it
1.Redis The longest is used for caching , It is the first middleware to realize distributed cache
2.Redis Can be used as a database , Realize such as like , Focus on , Ranking and other Internet demand with high performance requirements
3.Redis It can be used as a calculation tool , At a very small cost , Statistics such as PV/UV, User online days and other data
4.Redis There are many other scenarios , for example : Distributed locks can be implemented , It can be used as a message queue .
Redis How is it different from traditional relational database ?
Redis It's based on key value pairs NoSQL database , The value of key value pair is composed of a variety of data structures and algorithms .Redis All the data is stored in memory , So its speed is amazing , The reading and writing performance can reach 10 ten thousand / second , Far beyond relational databases
Relational database is based on two-dimensional data table to store data , Its data format is more rigorous , And support relationship query . The data of relational database is stored on disk , It can store a large amount of data , But the performance is far inferior to Redis
difference :
NoSQL Store in memory , Relational databases are stored on disk
Redis What are the data types
1.Redis Support 5 Core data types in , They are strings , Hash , list , aggregate , Ordered set
2.Redis It also provides Bitmap,HyperLogLog,Geo type , But these are based on the above core data types
3.Redis stay 5.0 The new increased Streams data type , It's a powerful 、 Support multicast 、 Persistent message queue .
Redis Why is it single threaded but so fast
1. Single thread avoids the consumption caused by thread switching and contention
2.Redis Most operations are done in memory
3.Redis Adopted IO Multiplexing mechanism , Make it on the Internet IO A large number of client requests can be processed simultaneously in the operation , Achieve high throughput .
set and zset What's the difference
set: I.e. set
The elements in the collection are unordered 、 Non repeatable , A collection can store up to 232-1 Elements ;
In addition to supporting the addition, deletion, modification and query of elements , It also supports the intersection of multiple sets 、 Combine 、 Difference set .
zset: It's an ordered set
Ordered sets retain the feature that set elements cannot be repeated ;
An ordered set sets a score for each element , And take this as the basis for sorting ;
Ordered collections cannot contain the same elements , But the scores of different elements can be the same .
1.7 The way Redis Medium watch command
Refer to the answer
A lot of times , Ensure that the data in the transaction has not been modified by other clients before executing the transaction .Redis Provides watch Command to solve such problems , This is an optimistic lock mechanism . Client pass watch command , Require the server to one or more key To monitor , If before the client executes the transaction , these key There is a change , The server will refuse to execute the transaction submitted by the client , And return a null value to it .
1.8 say something Redis in List Structure related operations
Refer to the answer
Lists are linearly ordered data structures , Its internal elements can be repeated , And a list can store up to 2^32-1 Elements . The list contains the following common commands :
lpush/rpush: From the left side of the list / Add data on the right ;
lrange: Specify the index range , And return the data in this range ;
lindex: Returns the data at the specified index ;
lpop/rpop: From the left side of the list / A data pop-up on the right ;
blpop/brpop: From the left side of the list / A data pop-up on the right , If the list is empty, it will enter the blocking state .
1.9 How do you design Redis The expiration time of ?
Refer to the answer
No expiration time is set for hotspot data , To achieve “ Physics ” The on the never expires , It can avoid the problem of cache breakdown ;
When setting the expiration time , You can attach a random number , Avoid a lot of key At the same time , Cause cache avalanche .
边栏推荐
- Practice of real-time push demo of three web messages: long polling, iframe and SSE
- Solve flask integration_ Error reporting in restplus
- 【CodeForces】Educational Codeforces Round 132 (Rated for Div. 2)
- [task02: SQL basic query and sorting]
- Store and guarantee rancher data based on Minio objects
- 83.(cesium之家)cesium示例如何运行
- 产品经理访谈 | 第五代验证码的创新与背景
- 平均海拔4000米!我们在世界屋脊建了一朵云
- Linxu [permission, sticky bit]
- Regular symbol description
猜你喜欢
Data mining (data preprocessing) -- Notes
Use of DDR3 (axi4) in Xilinx vivado (1) create an IP core
CNN convolution neural network learning process (weight update)
Solve the cookie splitting problem (DP)
Solve the problem that the nocturnal simulator cannot access the Internet after setting an agent
Merge sort template
WUST-CTF2021-re校赛wp
Use of DDR3 (axi4) in Xilinx vivado (2) read write design
Raspberry connects EC20 for PPP dialing
The product power is greatly improved, and the new Ford Explorer is released
随机推荐
MySQL startup error 1607 unexpected process termination
产品力大幅提升 新款福特探险者发布
Merge sort template
[task03: complex query methods - views, subqueries, functions, etc.]
【CodeForces】Educational Codeforces Round 132 (Rated for Div. 2)
Extract China map from global.Nc data and calculate regional CO2 value based on acgis
C language data 3 (1)
Pytorch model parameter assignment - tensor.copy_ () method
[pytorch] LSTM neural network
太空射击第11课: Sound and Music
LeetCode_ Bit operation_ Medium_ 260. Number III that appears only once
C language - question brushing column
Wust-ctf2021-re school match WP
超大模型工程化实践打磨,百度智能云发布云原生AI 2.0方案
[fasttext -- Summary notes]
Other IPS cannot connect to the local redis problem solving and redis installation
Shanghai Jiaotong University joined hands with Taobao to set up a media computing laboratory: promoting the development of key technologies such as video super score
[detailed use of doccano data annotation]
最大交换[贪心思想&单调栈实现]
The product power is greatly improved, and the new Ford Explorer is released