1. Redis cache consistency problem = how to ensure consistency between the data in the cache and the data in the database?
One, the two commonly used modes of redis
Note that the following two modes will have certain vulnerabilities under large concurrency.
1.1, double write mode
While modifying the database, modify the cache. If there are two concurrent operations, the first modification of the database is delayed (due to various reasons), during this period the second modification is performed, followed by the second modification cache. The first modification cache is executed last, which leads to the appearance of dirty data.
1.1.1. Solution one of dual writing mode------------>Locking method
The two operations of writing to the database and writing to the cache can be implemented by locking. A set of write database and write cache are executed before the second execution.