When Redis is used as a distributed cache, how do you solve the problem of data update?

redis as a cache feature has many advantages, which can ease the pressure on the server
first determine whether there is any in the cache. If not, check DB
, then directly use
. What if DB is updated? Isn"t the data in redis just the old dirty data?

Jan.08,2022

immediately update the redis cache data after updating the redis data. You can use message queuing and other methods to update the cache immediately, add a timeout elimination, and set the expiration time for the cache. If there is a problem with the active update, the dirty data will also be expired and deleted.


1. After the new DB, you can directly let the cache expire. The next query will check the database first, and then save it to redis.
2. Use queues to update asynchronously.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf4be1-46f63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf4be1-46f63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?