Files
fuwari-blog/src/content/posts/中间件/Redis/RedisZset实现原理.md
2025-09-11 23:28:48 +08:00

27 lines
820 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: RedisZset实现原理
published: 2025-09-11
description: ''
image: ''
tags: ['Redis']
category: '中间件 > Redis'
draft: false
lang: ''
---
# Redis ZSet实现原理
是一种由跳表和哈希表组成的数据结构。ZSet结合了集合的特性和排序功能能存储具有唯一性的成员并且根据成员的分数进行排序。
- 跳表: 用于存储数据的排序和快速查找
- 哈希表: 用于存储成员和它分数的映射,提供快速查找
当元素数量较少的时候Redis采用压缩列表来节省内存。
元素个数<=zset-max-ziplist-entries并且每个元素的值小于zset-max-ziplist-value
如果任何一个条件都不满足Zset采用跳表加哈希表作为底层实现。
![](https://blog.meowrain.cn/api/i/2025/09/11/12i8qms-1.webp)