What are the underlying data structures used for Redis?

Technology CommunityCategory: RedisWhat are the underlying data structures used for Redis?
VietMX Staff asked 3 years ago

Here is the underlying implementation of every Redis data type.

  • Strings are implemented using a C dynamic string library so that we don’t pay (asymptotically speaking) for allocations in append operations. This way we have O(N) appends, for instance, instead of having quadratic behavior.
  • Lists are implemented with linked lists.
  • Sets and Hashes are implemented with hash tables.
  • Sorted sets are implemented with skip lists (a peculiar type of balanced trees).
  • Zip List
  • Int Sets
  • Zip Maps (deprecated in favour of zip list since Redis 2.6)

It shall be also said that for every Redis operation you’ll find the time complexity in the documentation so if you are not interested in Redis internals you should not care about how data types are implemented internally really.