I write code for several projects, open redis, fetch data to the variable, open mysqli, insert data to the database, and add the script to cron. I feel that there are a lot of repetitive code, so I would like to ask if there are some common and efficient code for re... I write code for several projects, open redis, fetch data to the variable, open mysqli, insert data to the database, and add the script to cron.
I feel that there are a lot of repetitive code, so I would like to ask if there are some general and efficient frameworks that are used to persistently store data in redis to mysql?
Reply content:
I write code for several projects, open redis, fetch data to the variable, open mysqli, insert data to the database, and add the script to cron.
I feel that there are a lot of repetitive code, so I would like to ask if there are some general and efficient frameworks that are used to persistently store data in redis to mysql?
1. first, even if the framework is used, what it does will be retrieved from redis and then persisted to mysql, which does not reduce the operations on the data layer, the framework does not need to be written in your code. (Only one advantage ).
2. Data structure and persistence. Redis storage format is mostly K-V, Key is generally the primary Key ID, and VALUE is generally JSON, and mysql is how, mysql is a field, that is to say, you still need to convert the Json into a javabean and then persist it. So if your data structure is fixed, you can consider writing a script for regular processing. if your data is changed, you should manually control it, otherwise, what is the difference between changing your script and writing two lines of code?
Summary: The framework cannot solve the problem of adapting your redis to mysql complex data formats. It would be nice to maintain a timer for a simple data structure. If you need to do this, you need to find a problem and the bug is not controlled yet.
SetredisData in the persistent storagemysql.
redisUsed as a cache, data comes from the data persistence layer.
For search engines, suchsolrAndmysqlIn this case, you can consider data persistence to the database.