Redis Datastructure
Redis 数据结构 逻辑类型 (Type) 底层数据结构 (Internal Encoding) String int, embstr, raw (SDS) List quicklist Hash listpack, hashtable Set intset, hashtable ZSet listpack, skiplist + hashtable graph TD A[redisObject] --> B{type} B -->|STRING| C[int / embstr / raw] B -->|LIST| D[quicklist] B -->|HASH| E{size?} B -->|SET| F{all int?} B -->|ZSET| G{size?} E -->|小| H[listpack] E -->|大| I[hashtable] F -->|yes & 少| J[intset] F -->|no| K[hashtable] G -->|小| L[listpack] G -->|大| M[skiplist + hashtable]每种类型根据数据量自动切换编码:小数据用紧凑结构省内存,大数据切高效结构保性能。 ...