Get the App
SLTechnology News&Howtos  ›  Database  › 

Principle of writing / querying data in Redis cluster (theory)

Shulou Source: shulou.com Published: 2022-06-01 13:04:56 11月14日 Update

Redis Cluster Data Storage Principle:

In redis cluster, if you want to store a key-value,

This key is first residuated by CRC16 (and 16384),

The result corresponds to a hash slot between 0 and 16383.

Finally, redis cluster places the key-value in the corresponding hash slot.

Redis Cluster Data Acquisition Principle:

When a client sends a command related to a database key to any node in the redis cluster,

The node receiving the command calculates which hash slot the key to be processed belongs to,

And check whether this hash slot belongs to itself (jurisdiction):

If the slot where the key is located happens to belong to itself (jurisdiction), the node will directly execute the key-related command.

If the slot where the key is located does not belong to itself (jurisdiction), then the node will return a MOVED error to the client,

Direct the client to the node responsible for the corresponding slot, and the client needs to send the key-related command it wants to execute again.

Tags: Node command data hash principle cluster location accounting again customer client database algorithm result error processing storage correlation check Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Shulou Technology Shulou Information Microsoft