Home > Database > Redis > Redis various data types underlying data storage structure

Redis various data types underlying data storage structure

下次还敢
Release: 2024-04-19 19:54:15
Original
632 people have browsed it

Redis data types use different underlying storage structures: String: Simple Dynamic String (SDS) Hash: Hash table, use linked list or jump table to process hash collision list: Doubly linked list Collection: Ha Hash table or integer collection, using Bloom filter Sorted collection: skip table or dictionary Geospatial index: skip table or R tree

Redis various data types underlying data storage structure

Redis Data type underlying storage structure

Redis is a high-performance NoSQL database that supports multiple data types, each type uses a different underlying storage structure.

String (string)

  • Underlying storage structure: simple dynamic string (SDS)
  • SDS uses pre-allocated memory to reduce Memory allocation and deallocation overhead.
  • SDS can store binary or text data and supports efficient splicing and modification operations.

Hash(hash)

  • Underlying storage structure: Hash table
  • The hash table uses the hash function to Keys map to values.
  • Each key is stored in the hash table and is represented by a pointer to the value.
  • For each hash bucket, use a linked list or skip table to store hash collisions.

List (list)

  • Underlying storage structure: doubly linked list
  • Doubly linked list links elements into a sequential list.
  • Each element in the linked list stores a pointer to the next element and the previous element.
  • Linked lists support efficient insertion, deletion and search operations.

Set

  • Underlying storage structure: hash table or integer set
  • Use hash table to store elements , and use bloom filters for quick membership checks.
  • The integer collection is only suitable for storing integers and adopts a more compact storage structure.

Ordered set (zset)

  • Underlying storage structure: jump list or dictionary
  • The jump table organizes elements into Multi-layer linked list to achieve efficient ordered search.
  • Dictionaries store elements in hash tables and use skip tables to maintain order.

Geographic spatial index (geospatial)

  • Underlying storage structure: skip table or R tree
  • Jump table is used for storage The coordinates of a geospatial point.
  • R tree is a hierarchical structure used for efficient search and range queries.

The above is the detailed content of Redis various data types underlying data storage structure. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template