V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Acceml
V2EX  ›  问与答

[准备面试] Redis 数据结构及其内部实现关系

  •  
  •   Acceml · Mar 17, 2019 · 2172 views
    This topic created in 2608 days ago, the information mentioned may be changed or developed.

    image.png Redis 的数据结构的使用真的是美极了,笔者本人不是 redis 的专家,只是兴趣看了下源码,总结了一下他们之间的实现关系如上图所示。可能不全,供参考。

    建议看看源码以及分析,这完全是数据结构之美,时间和空间的权衡和折中。例如 hash 折中数据结构,元素少的时候,内存存储用的是 ziplist,这样是用时间换空间,但是元素多的时候,用的是 dict,又是用空间换时间。还用了我认为最简单漂亮的数据结构跳表。

    左边是 Redis 暴露给用户的数据结构:

    • String

    • Hash

    • List

    • Set

    • Sort Set 右边是 Redis 内部实现的数据结构:

    • sds

    • dict

    • ziplist

    • quicklist

    • skiplist

    • intset

    参考资料

    Redis 系列文章——合集

    热门阅读

    Leetcode 名企之路

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1000 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 18:58 · PVG 02:58 · LAX 11:58 · JFK 14:58
    ♥ Do have faith in what you're doing.