当前位置:网站首页>Redis memory optimization and distributed locking
Redis memory optimization and distributed locking
2022-06-13 03:15:00 【wks19891215】
One : Memory optimization .
(1) stay key In a large number of cases , Try to replace the string with a small hash table .
(2) because redis Default in hash key No more than 512,value No more than 64 Byte time , Use ziplist.
(3) Additional development is needed sharding function , To break up the big hash table .
The problem is coming. , In string form , Every key You can set the expiration time separately . Hash table does not support child key Set expiration , To do ?
terms of settlement : stay value Save time stamp in . Offline script scheduled scan .
This method is used in the case of a large amount of data , Memory can be compressed 3 About times .
Two : Distributed lock ( single redis example )
Distributed lock acquisition :set key value ex(30) nx
Release of distributed lock :(1) Use eval perform lua Scripts compare values . Delete when equal . Use lua Scripts are meant to ensure atomicity .
(2) If the task execution exceeds 30 What to do after seconds ? You can open threads to use expire Give him more time to live . Until the current task is completed , To release .
边栏推荐
- Radio design and implementation in IVI system
- KITTI数据集无法下载的解决方法
- JVM JMM (VI)
- 二叉树初始化代码
- 视频播放屡破1000W+,在快手如何利用二次元打造爆款
- Vs Code modify default terminal_ Modify the default terminal opened by vs Code
- Add Yum source to install php74
- Use of jstack
- 【 enregistrement pytorch】 paramètre et tampon des variables pytorch. Self. Register Buffer (), self. Register Paramètre ()
- Linked list: reverse linked list
猜你喜欢

Installing the IK word breaker

Radio design and implementation in IVI system

SQL execution process in MySQL (3)

Unified scheduling and management of dataX tasks through web ETL

C # simple understanding - method overloading and rewriting

Open source - campus forum and resource sharing applet

Spark UDF instance details

English语法_方式副词-位置

Scala implements workcount
![[JVM Series 5] performance testing tool](/img/94/b9a93fc21caacaf2a2e6421574de5c.jpg)
[JVM Series 5] performance testing tool
随机推荐
[JVM Series 5] JVM tuning instance
How to manage the IT R & D department?
二叉树初始化代码
Applet image component long press to identify supported codes
Scala implements workcount
Mongodb index -index
IOS interview · full bat interview record of an IOS programmer (including the true interview questions of Baidu + Netease + Alibaba)
English语法_频率副词
C method parameter: ref
Use of jstack
A personal understanding of interpreted and compiled languages
【同步功能】2.0.16-19 版本都有同步功能修复的更新,但未解决问题
Stack information, GC statistics
通过Web ETL统一调度和管理DataX任务
Delete the number of a range in the linked list
Binary tree initialization code
IOS development interview knowledge sorting - OC Foundation (II)
When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed
C# . NET ASP. Net relationships and differences
Hash table: whether alien languages are sorted