当前位置:网站首页>Interviewer: do you understand redis' shared object pool?
Interviewer: do you understand redis' shared object pool?
2022-06-27 13:16:00 【51CTO】
I'm waiting anxiously in the interview room , Suddenly I heard footsteps outside the door , The door is then opened , The young man with clean clothes and beautiful face came in , A faint fragrance of men's perfume comes to us. .
interviewer :“ Usually used in work Redis Do you ?”
I :“ It's used a lot .” I'm happy in my heart ,Redis I'm familiar with it , What are the five data types 、 The two persistence methods are back to back .
interviewer :“Redis Shared object pool, see ?”
“ This .. Not much in-depth understanding .” I hesitated , The palms of my hands are already sweating .
interviewer :“ Go back and wait for the news .”
This sentence is clear , And then there's no then . Failure is the mother of success , I'm not discouraged , Decided to mend it right away .
Shared object pool
Creating a large number of duplicate integer types is bound to consume a lot of memory , So in Redis Internally maintained a from 0 To 9999 Integer object pool for , This is it. Shared object pool .
To verify and understand , We use object refcount Command to check the number of object references , The effect is as follows :
Set up one-more-num1 by 404 after , Directly use integer objects in the shared pool , So the number of references is 2( Another reference is on the object pool ); To set up one-more-num2 by 404 after , The number of references becomes 3.
But here's the thing : When setting the maximum memory value (maxmemory) And enable LRU Relevant elimination strategies ( Such as :volatile-lru、allkeys-lru) when , Shared object pools will be disabled .
Why is there no string object pool ?
A key operation in the shared object pool is to determine whether objects are equal .
Redis There are only integer type object pools in the , Because the time complexity of integer comparison algorithm is O(1), Only kept 10000 An integer to prevent excessive waste of the object pool .
Relatively speaking , The time complexity of string comparison algorithm is O(n), In particular, the comparison of long strings is more performance consuming .
and , There is a high probability that integer types will be reused , The probability that a string will be reused is much lower than , So in Redis Only integer type objects are shared in the pool .
Interviewer, you'll see , You don't care about me today , Tomorrow I'll keep you up , Ha ha ha ...
reference :
《Redis Design and implementation 》
《Redis Development and operations 》
《Redis Deep Adventure : Core principles and application practice 》
I've seen it here , You and I must be predestined friends , Leave your give the thumbs-up and Focus on , It will become a great thing in the future .
边栏推荐
- JSON.stringify用法
- ViewPager2使用记录
- Hue new account error reporting solution
- Airbnb double disk microservice
- A pang's operation record
- Implementation of recruitment website based on SSM
- 微服务如何拆分
- TCP 流控问题两则
- Deploy redis sentinel mode using bitnamiredis Sentinel
- How to open an account for CSI 500 stock index futures, what are the regular domestic stock index futures platforms, and where is the safest place to open an account?
猜你喜欢
随机推荐
How to modify a node_ Files in modules
Tiktok practice ~ public / private short video interchange
JSON.stringify用法
dynamic programming
printf不定长参数原理
Cool in summer
Make learning pointer easier (1)
C语言 函数指针与回调函数
硬件开发笔记(七): 硬件开发基本流程,制作一个USB转RS232的模块(六):创建0603封装并关联原理图元器件
快讯:华为启动鸿蒙开发者大赛;腾讯会议发布“万室如意”计划
A pang's operation record
Istio微服务治理网格流量管理核心资源控制器详解
[medical segmentation] unet3+
How to open an account for CSI 500 stock index futures, what are the regular domestic stock index futures platforms, and where is the safest place to open an account?
每日刷题记录 (六)
Two TCP flow control problems
Centos7命令行安装Oracle11g
Airbnb复盘微服务
VS调试技巧
【第27天】给定一个整数 n ,打印出1到n的全排列 | 全排列模板








