当前位置:网站首页>Interviewer: what is the internal implementation of the list in redis?
Interviewer: what is the internal implementation of the list in redis?
2022-07-03 10:46:00 【51CTO】
While waiting in the interview room , It feels so warm , My cold rental house has to be covered with two layers of quilt to sleep . I was about to take off my coat , I suddenly heard footsteps outside the door , The door is then opened , A little sister with curved eyebrows and red lips came in , The smell of sweet perfume immediately went into my nostrils. .
The interviewer's little sister smiled and said :" Hello! , I'm the interviewer today , So let's start !”
I put away my straight eyes and hurriedly said :“ well , well .”
The interviewer's little sister said :“Redis What are the basic data types in ?”
I answered immediately :“Redis The basic data types of are : character string (string)、 list (list)、 Hash (hash)、 aggregate (set)、 Ordered set (zset).”
The interviewer's little sister said :“ What is the internal implementation of the list type ?”
I thought about it and wanted to answer :
There are two kinds of internal codes for lists : Compressed list (ziplist) And the list (linkedlist). Compressed list (ziplist) It is a sequential data structure composed of a continuous memory . A compressed list can contain any number of nodes , A byte array or integer value can be saved on each node . Linked list (linkedlist) Is passed by multiple nodes prev and next A two-way linked list composed of pointers . When the number of list elements is small and each element takes up less space , Use compressed lists . When there are a large number of list elements or an element takes up a large space , Use the list .
The interviewer's little sister said :“ You're talking about the internal code of the old version ,3.2 What does the implementation look like after version ?”
I was also immersed in the complacency of the last question , Suddenly, his expression solidified , The palms began to sweat .“ This .. Not much in-depth understanding ”, I hesitated .
The interviewer's little sister said :“ Go back and wait for the news .”
This sentence is clear , I know there is no “ then ” 了 , But not discouraged, I asked :“ Could you give me a hint ?”
The interviewer's little sister smiled and said :“ Certainly. , stay 3.2 Version start , Using a quick list (quicklist) As the internal code of list type . Quick list (quicklist) Is to compress the list (ziplist) A linked list of nodes (linkedlist), Divide the linked list into segments , Each segment uses a compressed list for continuous memory storage , Multiple compressed lists through prev and next A two-way linked list composed of pointers . It combines the advantages of compressed list and linked list , Further compress the memory usage , Further improve efficiency .”
On the way home , I think about it : You can't read , We also need to pay attention to the continuous development and evolution of Technology . Although the interview was inconclusive , But it's not without harvest .
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 .
边栏推荐
- [ultra detailed] implement soft and hard interval SVM based on sklearn
- Introduction to deep learning linear algebra (pytorch)
- Traversal of map set
- Ut2017 learning notes
- [combinatorial mathematics] pigeon's nest principle (simple form of pigeon's nest principle | simple form examples of pigeon's nest principle 1, 2, 3)
- Leetcode skimming ---374
- Unity learning notes: online game pixel Adventure 1 learning process & error correction experience
- Binary search method
- 安装yolov3(Anaconda)
- Preliminary knowledge of Neural Network Introduction (pytorch)
猜你喜欢
Tensorflow—Neural Style Transfer
2021-09-22
How to hide cvxpy warnings: warn: a- > P (column pointers) not strictly increasing, column x empty?
Jetson TX2 brush machine
Tensorflow - tensorflow Foundation
Jupiter notebook changing font style and font size
Ut2014 supplementary learning notes
C#项目-寝室管理系统(1)
安装yolov3(Anaconda)
深度学习入门之线性回归(PyTorch)
随机推荐
Flink <-->JDBC的使用介绍+with参数
Leetcode skimming ---852
Uni app learning 1 bottom menu and parent-child components
【吐槽&脑洞】关于逛B站时偶然体验的弹幕互动游戏魏蜀吴三国争霸游戏的一些思考
QT:QSS自定义 QSplitter实例
Buy health products for parents
面试官:Redis中列表的内部实现方式是什么?
Ind FHL first week
带你走进云原生数据库界扛把子Amazon Aurora
Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported
Leetcode刷题---75
Numpy quick start (III) -- array advanced operation
[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B
Pour vous amener dans le monde des bases de données natives du cloud
8、 Transaction control language of MySQL
Leetcode skimming ---75
Ut2014 supplementary learning notes
Nuget add reference error while installing packages
[ultra detailed] implement soft and hard interval SVM based on sklearn
Leetcode skimming ---189