Redis Cluster Design key

Source: Internet
Author: User
Tags redis cluster

1: Convert the table name to the key prefix such as User:

2:2nd place the field for the Zone key--the column name corresponding to the primary key in MySQL, such as UserID

3:3rd paragraph Place primary key value, such as 2,3,4 ...., A, B, c

4:4th paragraph, write the name of the column to be stored

Users table user, convert to key-value storage

Userid

Username

Passworde

Email

9

Lisi

1111111

[Email protected]


Set User:userid:9:username Lisi

Set User:userid:9:password 111111

Set user:userid:9:email [email protected]


Keys user:userid:9*


2 Note :

In the relational data, in addition to the primary key, there may be other columns also step query,

As in the above table, username is also very frequently queried, often this column is also indexed.

Converted to k-v data, a corresponding Key-value is generated for the column.

Set User:username:lisi:uid 9

In this way, we can find out userid=9 according to Username:lisi:uid,

Check User:userid:9:password/email again ...

Redis Cluster Design key

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.