My website mostly use Django + Mysql and sometimes Redis for some frequently access data.
My problem is how to sync data from Mysql to Redis automatically when I write data to Mysql by Django admin page.
Thank you for giving me some advice. It also will be appreciated if someone can tell me how to write data into Redis directly by Django admin page
Thank you!
What you want to achieve looks like using Redis as a cache. The pattern is:
Always look for the data in redis
If it's not in redis, get it from MySQL and store it in Redis with an expiration date, using the expire command
Doing it like this, you have to modify you app, not the admin page. But there could be a delay between the writing of the informations in the admin page, and their availability to the clients.
You may delete the data from the Redis cache in the admin, when storing them, to ensure the newest version will always be delivered. But you will have to modify Django admin page for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With