Issues to be aware of using Redis caching data and some personal thinking and understanding _redis

Source: Internet
Author: User
Tags redis cluster

Read the table of Contents General Redis logical Redis Cache What will be the problem. Redis what data is appropriate for caching. Redis Cluster

Before I have a blog has tried to use Redis, in the actual project is very important. At least it plays a vital role in the frequent reading of data.

But with the study of technology, slowly business to complicate, later may use to Redis cluster, so in this side of the query some information, do some thinking and understanding.

If there is a problem, please put forward, humbly accept, seriously study.

The General Redis logic

Request to come over, redis inside there is not. Give it to a user

Database not queried

Is there any in the database? Did not tell the user no

There is a query out, to the user, and stored to the Redis

There is something wrong with the Redis cache.

Redis caching database data, one thing is particularly important, that is the problem of data consistency.

When a single database is multithreaded, if it is not a database lock, there is a lot of data inconsistency, and I don't have to say much about it here.

Redis Cache will also have the problem, that is, the database data update to Redis there will be a time lag, such a time difference will lead to inconsistent data.

For example, a commodity price in the database is 500, and then Redis is also 500, but suddenly the database changed to 600, if all users are read into the database, the database will be locked, and then avoid users read the previous 500, but Redis update how to say there is a time lag, So it is possible for the user to read the 500 data.

This is the problem of inconsistent data.

Redis what data is appropriate for caching.

The data here is divided into two pieces, the first is the data of the database, and the second is some static data of the page.

Here is the data of the database.

Some of the static data on the page is not suitable for storing in the cache.

The data that is presented above is then inconsistent, so the cached data is also required.

Do not cache data that is highly demanding for data consistency.

If this data is possible to be modified, it is best not to save the cache, or not to put the database, just put the cache.

Data that is less consistent with data is available.

One thing to emphasize is that if this data is released, however, the operation of this data is not modified, but only deleted, but also can be cached, because in practice, if a delete operation is executed, the cache can be deleted first, so as to ensure that no user can read the deleted data, The database is then deleted.

Redis Cluster

Redis cluster, this side I give the suggestion is the use of Redis master-slave copy function, this function and MySQL master-slave replication is a truth, can be a good guarantee of data consistency.

Specific Redis cluster configuration and experiments I will give in the new blog later.

To sum up: the specific use of the process, the use of Redis timeout can be a number of data to carry out some persistent management, for some data consistency is not high data cache, make reading speed, use Redis cluster can be used master-slave copy function, Redis cluster has no central node, With replication and failover features, this avoids a single node becoming a performance bottleneck, or the entire cluster is offline because a node is offline.

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.