Now the project uses Redis, which greatly improves the efficiency of data extraction, but if the logic is handled carelessly, it will give itself a pit
1. Completely rely on REDIS data provided in the background, when the Redis occupancy rate is high when the reboot (generally not landed), data loss.
When the data has not been loaded from the database to Redis, and there is new data to write at this time, when the cache is read again, the cache exists and is displayed directly. Causes the displayed data to be incorrect
There are two ways to solve this problem:
Pre-loading at the main entrance to solve the problem of Redis restart, but when there is no data to be cached, it will cause frequent sweep of the library
When inserting the data when Zadd, do exists key existence judgment, only in the case of the existence of the cache is added. When used, the full load is done
2. In some scenarios, you can determine whether the data is displayed based on the cache. It is best to deal with the non-display, only the content, not clear its key, with the content to determine whether the display.
Otherwise, do not display the case of deleting key, resulting in key does not exist, and large-scale sweep of the database, to the database pressure