Skip to content

Commit

Permalink
Update object-encoding doc to mention all the encodings (#2677)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin authored Mar 5, 2024
1 parent 9e15309 commit 66da565
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions commands/object-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,34 @@ Redis objects can be encoded in different ways:
- `embstr`, an embedded string, which is an object where the internal simple dynamic string, `sds`, is an unmodifiable string allocated in the same chuck as the object itself.
`embstr` can be strings with lengths up to the hardcoded limit of `OBJ_ENCODING_EMBSTR_SIZE_LIMIT` or 44 bytes.

* Lists can be encoded as `ziplist` or `linkedlist`. The `ziplist` is the special representation that is used to save space for small lists.
* Sets can be encoded as `intset` or `hashtable`. The `intset` is a special encoding used for small sets composed solely of integers.
* Hashes can be encoded as `ziplist` or `hashtable`. The `ziplist` is a special encoding used for small hashes.
* Sorted Sets can be encoded as `ziplist` or `skiplist` format. As for the List type small sorted sets can be specially encoded using `ziplist`, while the `skiplist` encoding is the one that works with sorted sets of any size.
* Lists can be encoded as:

- `linkedlist`, simple list encoding. No longer used, an old list encoding.
- `ziplist`, Redis <= 6.2, a space-efficient encoding used for small lists.
- `listpack`, Redis >= 7.0, a space-efficient encoding used for small lists.
- `quicklist`, encoded as linkedlist of ziplists or listpacks.

* Sets can be encoded as:

- `hashtable`, normal set encoding.
- `intset`, a special encoding used for small sets composed solely of integers.
- `listpack`, Redis >= 7.2, a space-efficient encoding used for small sets.

* Hashes can be encoded as:

- `zipmap`, no longer used, an old hash encoding.
- `hashtable`, normal hash encoding.
- `ziplist`, Redis <= 6.2, a space-efficient encoding used for small hashes.
- `listpack`, Redis >= 7.0, a space-efficient encoding used for small hashes.

* Sorted Sets can be encoded as:

- `skiplist`, normal sorted set encoding.
- `ziplist`, Redis <= 6.2, a space-efficient encoding used for small sorted sets.
- `listpack`, Redis >= 7.0, a space-efficient encoding used for small sorted sets.

* Streams can be encoded as:

- `stream`, encoded as a radix tree of listpacks.

All the specially encoded types are automatically converted to the general type once you perform an operation that makes it impossible for Redis to retain the space saving encoding.

0 comments on commit 66da565

Please sign in to comment.