Home >Backend Development >PHP Tutorial >Is there any excellent ready-made framework for persistently storing data in redis into mysql?

Is there any excellent ready-made framework for persistently storing data in redis into mysql?

WBOY
WBOYOriginal
2016-08-25 10:37:181556browse

I write my own code for several projects now, open redis, get data into variables, then open mysqli, insert data into the database, and then add this script to cron.
I feel like there is a lot of repetitive code here, so I would like to ask if there are some common and efficient excellent frameworks in the industry for persistently storing data in redis to mysql?

Reply content:

I write my own code for several projects now, open redis, get data into variables, then open mysqli, insert data into the database, and then add this script to cron.
I feel like there is a lot of repetitive code here, so I would like to ask if there are some common and efficient excellent frameworks in the industry for persistently storing data in redis to mysql?

1. First of all, even if you choose a framework, what it does is to take it out from redis and then persist it to mysql. It does not reduce the operations of the data layer, but the framework does it for you without having to write it in your code. (An advantage only).
2. Data structure and persistence. The format of Redis storage is mostly K-V. Key is usually the primary key ID, and VALUE is usually JSON. What about mysql? Mysql is a field, that is, Json still needs to be converted into javabean and then persisted. So if your data structure is fixed, you can consider writing a script for regular processing. If your data changes, then you should control it manually. Otherwise, what is the difference between changing your script and writing 2 more lines of code?

Summary: The framework cannot solve your problem of adapting the complex data format from redis to mysql. It would be nice if it was just a simple data structure that maintained a timer. Why go to extra trouble and cause trouble? If a bug occurs, it may not be controllable.

Persistent storage of data in redis into mysql is not recommended by me.
redis is used as a cache, and the data comes from the data persistence layer.
If it is a search engine, such as solr and mysql, in this case, you can consider persisting data to the database.

Statement:
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
Previous article:Problem with readline.soNext article:Problem with readline.so