当前位置:网站首页>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 .
边栏推荐
- Leetcode刷题---704
- 如何在游戏中制作一个血条
- Detailed cross validation and grid search -- sklearn implementation
- 神经网络入门之矩阵计算(Pytorch)
- ThreadLocal principle and usage scenario
- Ut2015 learning notes
- Linear regression of introduction to deep learning (pytorch)
- C#项目-寝室管理系统(1)
- Leetcode刷题---189
- Iterator iterator enhances for loop
猜你喜欢

深度学习入门之线性回归(PyTorch)

Linear regression of introduction to deep learning (pytorch)

Install yolov3 (Anaconda)

Tensorflow—Image segmentation

UI interface design related knowledge (I)

一个30岁的测试员无比挣扎的故事,连躺平都是奢望

深度学习入门之自动求导(Pytorch)

Ut2014 learning notes
![[combinatorial mathematics] pigeon nest principle (simple form examples of pigeon nest Principle 4 and 5)](/img/0b/8dac418b32422f46a643158485c40f.jpg)
[combinatorial mathematics] pigeon nest principle (simple form examples of pigeon nest Principle 4 and 5)

Pytoch has been installed, but vs code still displays no module named 'torch‘
随机推荐
Ind FHL first week
Practical part: conversion of Oracle Database Standard Edition (SE) to Enterprise Edition (EE)
Jetson TX2 刷机
Adaptive Propagation Graph Convolutional Network
Pytoch has been installed, but vs code still displays no module named 'torch‘
Mysql--索引原理+如何使用
Ut2011 learning notes
Tensorflow—Image segmentation
[ultra detailed] implement soft and hard interval SVM based on sklearn
Ind wks first week
Leetcode skimming ---44
Leaders always entrust the work to flattering employees
小文件专项
[combinatorial mathematics] pigeon nest principle (simple form examples of pigeon nest Principle 4 and 5)
分组函数之rollup、cube函数、grouping sets函数
Drop out (pytoch)
Type de contenu « Application / X - www - form - urlencoded; Charset = utf - 8 'not supported
大型电商项目-环境搭建
Leetcode skimming ---263
[untitled] numpy learning