当前位置:网站首页>[redis] summary of common knowledge points
[redis] summary of common knowledge points
2022-07-21 07:52:00 【Baking soda】
Basics
Redis Why so soon?
- Memory based ;
- Single thread reduces context switching , At the same time, atomic ;
- IO Multiplexing ;
- Advanced data structure ( Such as SDS、Hash And jump tables )
Four cache problems and solutions ?
Cache avalanche :
redis The cache key A large number of failures at the same time , As a result, a large number of requests are all sent to the database , Cause the database to hang up
resolvent :
- Random setting key The expiration time of
- Hot data key Never expire
- Run timed tasks , Refresh the new cache before it expires
Cache penetration
Yes redis And in the database No data to constantly query , Cause the database to hang up
resolvent
- Check the parameters
- Cache nonexistent data in redis In cache , Set up k-v All for null, And set a short expiration time
- The bloon filter
Cache breakdown
Specific hot spots key Has been high concurrency ,key Sudden failure , The database is under too much pressure and goes down
resolvent
- Set hot spots key Never expire
- Add mutex lock , The first queried data is put into the cache , Go cache , Update the cache every time
Cache preheating
Cache hot data in advance to redis in , Prevent database downtime due to excessive pressure
resolvent
- Write hotspot cache manually
How to ensure the consistency between cache and database data ?
Update the database first , Delete the cache
because Cache write speed Far greater than Write speed of the database , Ensure that the cache is empty , Look up the database again , It can ensure that the data and cache are the same every time
How to ensure Redis High concurrency ?
Redis adopt Master slave plus cluster framework , Read and write separation , The master node is responsible for writing , And synchronize the data to other slave nodes , The slave node is responsible for reading , To achieve high concurrency .
Redis How to guarantee atomicity ?
The answer is simple , because Redis It's single threaded , therefore Redis Provided API It's also atomic operation .But in our business, we often have the first get after set Common business , In the case of concurrency, it will lead to data inconsistency .
How to solve
- Use incr、decr、setnx Wait for atomic manipulation ;
- Client lock ;
- Use Lua Script implementation CAS operation .
redis Five basic data types and application scenarios
- String( character string ): cache 、 Current limiting 、 Distributed lock 、 Counter 、 Distributed Session etc. .
- Hash( Dictionaries ): User information 、 User home page visits 、 Combined query, etc .
- List( list ): Simple queue 、 Follow the list timeline .
- Set( aggregate ): Fabulous 、 Step on 、 Labels etc. .
- ZSet( Ordered set ): Ranking List 、 Friends list .
data storage
边栏推荐
- 第2讲 Hi3861的WiFi实验-API-3
- Analysis of LEGO Online Shopping Store
- Hcip notes day 8
- 最右×微帧,高质量的HEIF图片编码压缩技术
- 力扣sql刷题系列(三)
- Chapter 1 Introduction to creating rest services
- 【暑期每日一题】洛谷 P1157 组合的输出
- 第2讲 Hi3861的WiFi实验-API-4
- Redis學習筆記(1)——B站動力節點
- [security bulletin] Apache spark shell command injection vulnerability (cve-2022-33891) risk notification
猜你喜欢
C#/VB.NET在 Word 中插入水印
推荐一个 WordPress 付费主题站
Without the life of speculative stock, the best policy is to give up wisely and decisively
Grafana visual configuration chart stat
pytorch常见问题整理与解决方法
OCR/STR生僻字数据集生成 | PaddleOCR的垂类Fine-tune(1)
【C语言进阶】自定义类型——结构体的位段&&枚举&&联合体
2022.7.20 线性表
Redis学习笔记(1)——B站动力节点
云生态大会,随“峰”而来!
随机推荐
【暑期每日一题】洛谷 P6850 NOI
机器学习基础篇(3)之图像运算和变换
新建第一个HBuilder项目
grpc设置连接存活时间及服务端健康检查
Ultra-Light-Fast-Generic-Face-Detector-1MB的自定义数据集训练 | 多分类修改指南 (1)
【暑期每日一题】洛谷 P1605 迷宫
没有投机stock的命,该放弃的就明智果断放弃才是上策
力扣sql刷题系列(三)
[advanced C language] custom type - bit segment & enumeration & Union of structure
Chapter 1 Introduction to creating rest services
What is the difference between dall-e2 and imgen? Reddit hot post inventory effect difference
R语言epiDisplay包的idr.display函数获取泊松回归poisson模型的汇总统计信息(初始事件密度比IDR值、调整事件密度比IDR值及其置信区间、Wald检验的p值和似然比检验的p值
阿里云发布《升舱-数据仓库升级交付标准化》白皮书
OCR/STR生僻字数据集生成 | PaddleOCR的垂类Fine-tune(1)
Construction of Seata multilingual system
面试真题2
Redis学习笔记(1)——B站动力节点
不妨给“云面试”多些辅导
来面试阿里测试工程师,面试官问我未来3-5年规划,我给面试官画个大饼。
第一章 创建 REST 服务简介