当前位置:网站首页>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 .
边栏推荐
- OpenHGNN发布0.3版本
- 手把手教你搭一个永久运行的个人服务器!
- With the advent of the era of Internet of everything, Ruijie released a scenario based wireless zero roaming scheme
- 7 killer JS lines of code
- Three traversal methods of binary tree
- A pang's operation record
- Two TCP flow control problems
- 今日睡眠质量记录78分
- 快速搭建一个自己的访问国外网站,搭建ss并开启bbr快速上网
- Cloud native (30) | kubernetes' app store Helm
猜你喜欢

Journal quotidien des questions (6)

Postman如何设置成中文?(汉化)

GCC compiling dynamic and static libraries

Istio微服务治理网格流量管理核心资源控制器详解

IJCAI 2022 | greatly improve the effect of zero sample learning method with one line of code. Nanjing Institute of Technology & Oxford proposed the plug and play classifier module

Configuration management center of microservices

A pang's operation record

Ali an interview question: use two threads to output letters and numbers alternately

With the advent of the era of Internet of everything, Ruijie released a scenario based wireless zero roaming scheme

深信服X计划-系统基础总结
随机推荐
OpenHGNN发布0.3版本
TCP 流控问题两则
Privacy computing fat offline prediction
OpenFeign服务接口调用
同花顺能开户炒股吗?安全吗?
JSON. Stringify usage
ensp云朵配置
实现WordPress上传图片自动重命名的方法
诗歌一首看看
Centos7 command line installation Oracle11g
Full explanation of ThreadLocal source code (threadlocalmap)
Good luck today
[tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (I)
思考的角度的差异
Using FRP tool to realize intranet penetration
硬件开发笔记(七): 硬件开发基本流程,制作一个USB转RS232的模块(六):创建0603封装并关联原理图元器件
How to choose LAN instant messaging software
What is low code for digital Nova? What is no code
Principle of printf indefinite length parameter
IJCAI 2022 | 用一行代码大幅提升零样本学习方法效果,南京理工&牛津提出即插即用分类器模块