background
In high-concurrency business scenarios, the performance bottleneck of the database is often caused by excessive concurrent user access, so there will be a Redis buffer.
case
1. A write, B read,
Write: 1. Eliminate cache 2. Write operation (1s consumed for various reasons) 3. Update cache
Read: 1. Read cache 2. Read DB 3 update cache
Read before the successful write, will cause dirty data to be read, cache is not the latest data
Second, the separation of master and slave
In the same way, in the process of master-slave delay, the read operation will read dirty data
solve:
1. Elimination mechanism, every time after writing a data, to eliminate the cache every few seconds
2.binlog, Redis updates Redis according to the records in binlog