Communication between Redis and Mysql

Source: Internet
Author: User
I found some information and looked at it. My learning experience is as follows: 1Mysql updates RedisMysql updates Redis and uses memcache to communicate with mysql. Every update operation using mysqludf triggers the update redis operation. When there is a high concurrency, mysql is under great pressure, and each table needs to be added, deleted, modified, and triggered, and the Redis server is not easy to replace (do not know if there is any way ). 2R

I found some information and looked at it. Learning Experience: 1. Mysql updates Redis and uses memcache to communicate with mysql. With mysql udf, every update operation triggers the redis update operation. When there is a high concurrency, mysql is under great pressure, and each table needs to be added, deleted, modified, and triggered, and the Redis server is not easy to replace (do not know if there is any way ). 2 R

I found some information and looked at it. The learning experience is as follows:

1. Mysql updates Redis

Mysql updates Redis by referring to memcache for communication with mysql. Every update operation using mysql udf triggers the redis update operation. When there is a high concurrency, mysql is under great pressure, and each table needs to be added, deleted, modified, and triggered, and the Redis server is not easy to replace (do not know if there is any way ).

2 Redis updates Mysql

The simplest is to read redis-> write mysql. But in high concurrency, This is not suitable. Therefore, we consider using message queue to update Mysql at regular intervals.

However, when the primary key in the data is auto-increment, the current idea is as follows:

First, Redis uses tempId as the key, id is empty, and data is overwritten to the cache through mysql udf, for example, clearing the cache temporary data.

Second, the redis key value uses the uuid field instead of the Id, and then synchronizes the redis cache id through the mysql udf.

Third, Redis reads the latest auto-incrementing key Id value from the Mysql table, and Redis transmits the id.

When using Redis to update Mysql, you must pay attention to the positioning of Redis in the system. When using it as a cache server, you must plan the data to be stored and how long it will take.

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.