当前位置:网站首页>面试官:Redis中列表的内部实现方式是什么?
面试官:Redis中列表的内部实现方式是什么?
2022-07-03 09:34:00 【51CTO】
在面试间里等候时,感觉这可真暖和呀,我那冰冷的出租屋还得盖两层被子才能睡着。正要把外套脱下来,我突然听到了门外的脚步声,随即门被打开,一位眉毛弯弯嘴唇红红的小姐姐走了进来,甜甜的香水味立刻钻进了我的鼻孔。
面试官小姐姐微笑地说:"您好,我是今天的面试官,那么我们就开始吧!”

我收起直勾勾的眼睛连忙说:“好的,好的。”
面试官小姐姐说:“Redis中基本的数据类型有哪些?”
我立刻回答:“Redis的基本数据类型有:字符串(string)、列表(list)、哈希(hash)、集合(set)、有序集合(zset)。”
面试官小姐姐说:“列表类型的内部实现方式是什么?”
我想了想回答到:
列表的内部编码有两种: 压缩列表(ziplist)和链表(linkedlist)。压缩列表(ziplist)是由一个连续内存组成的顺序型数据结构。一个压缩列表可以包含任意多个节点,每个节点上可以保存一个字节数组或整数值。链表(linkedlist)是由多个结点通过prev和next指针组成的双向链表。当列表元素个数比较少并且每个元素占用空间比较小的时候,使用压缩列表。当列表元素个数比较多或者某个元素占用空间比较大的时候,使用链表。
面试官小姐姐说:“您说的是旧版本的内部编码,3.2版本之后的实现是什么样子的?”
我还沉浸在上一个问题的沾沾自喜中,顿时表情凝固了,手心开始冒出冷汗。“这个。。没有太深入了解”,我支支吾吾的说到。
面试官小姐姐说:“回去等消息吧。”
这句话说的干净利落,我知道已经没有“然后”了,但是不气馁的我问:“可不可以稍微提示一下?”
面试官小姐姐微笑地说:“当然可以,在3.2版本开始,使用了快速列表(quicklist)做为列表类型的内部编码。快速列表(quicklist)是以压缩列表(ziplist)为节点的链表(linkedlist),将链表按段切分,每一段使用压缩列表进行内存的连续存储,多个压缩列表通过prev和next指针组成的双向链表。它结合了压缩列表和链表的优势,进一步压缩了内存的使用量,进一步提高了效率。”
在回家的路上,我反思了一下:不能死读书,还需要关注技术的不断发展和进化。虽然这次面试没有结果,但也不是没有收获的。
参考文献:
《Redis设计与实现》
《Redis开发与运维》
《Redis 深度历险:核心原理与应用实践》
竟然已经看到这里了,你我定是有缘人,留下你的点赞和关注,他日必成大器。
边栏推荐
- Leetcode刷题---10
- Leetcode skimming ---1385
- Leetcode刷题---44
- Seata分布式事务失效,不生效(事务不回滚)的常见场景
- 神经网络入门之预备知识(PyTorch)
- [roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B
- Ut2017 learning notes
- Handwritten digit recognition: CNN alexnet
- Install yolov3 (Anaconda)
- Raspberry pie 4B installs yolov5 to achieve real-time target detection
猜你喜欢

Adaptive Propagation Graph Convolutional Network

A detailed explanation of vector derivative and matrix derivative
![[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B](/img/2a/c232b83e0acbb970884148bd2aadc1.png)
[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B

MySQL报错“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”解决方法

The story of a 30-year-old tester struggling, even lying flat is extravagant

The imitation of jd.com e-commerce project is coming

User recommendation preference model based on attention enhanced knowledge perception

Unity learning notes: personal learning project "crazy genius Edgar" error correction document

Free online markdown to write a good resume

Detailed cross validation and grid search -- sklearn implementation
随机推荐
Entropy method to calculate weight
ThreadLocal principle and usage scenario
I really want to be a girl. The first step of programming is to wear women's clothes
[combinatorial mathematics] pigeon nest principle (simple form examples of pigeon nest Principle 4 and 5)
Classification (data consolidation and grouping aggregation)
Simple real-time gesture recognition based on OpenCV (including code)
Unity学习笔记:个人学习项目《疯狂天才埃德加》纠错文档
6、 Data definition language of MySQL (1)
Knowledge map reasoning -- hybrid neural network and distributed representation reasoning
Handwritten digit recognition: CNN alexnet
Flink -- 内置函数(ALL)
Practical part: conversion of Oracle Database Standard Edition (SE) to Enterprise Edition (EE)
Multi-Task Feature Learning for Knowledge Graph Enhanced Recommendation
Ut2013 learning notes
Leetcode刷题---1385
[roast & brain hole] Some Thoughts on the bullet screen interactive game of Wei Shu Wu Three Kingdoms when visiting station B
Softmax 回归(PyTorch)
Ut2017 learning notes
六、MySQL之数据定义语言(一)
Unity学习笔记:联网游戏Pixel Adventure 1学习过程&纠错心得