Assume that the person with ID = 1 is in three custom groups: group_a, group_ B, and group_c.
Groud_disdeal of dongshi, group_school_123, group_area_2323, group_jiaoyanshi_2343
Others are people who are directly recommended and added to favorites. These may not be recorded as group keys, but they mean one thing.
Each group records the last modification time ts. The last modification time ts is to modify the latest time ts when there are modifications (such as deletion, addition, and change, the change time does not need to be consistent with that of the database ts.
When a query is required, check whether the group ID = 1 is added or not. If no,
Obtain the last modified ts of each group separately. If an inconsistency exists, you must re-obtain and update the level 2 Cache. Otherwise, you can directly obtain the Level 2 cache.
In this way, we need to record the personal data of each person during the push, the Ts of the group, the Ts of the East Division, the Ts of the school, and the Ts of the area, these ts can be the time ts during the push, rather than the Ts in any database.
For example, if someone recommends a resource to a person with ID = 1, it is certain that the user with ID = 1 must modify the data ts to the modified time ts. The next request, naturally, you need to obtain it again.
This idea of modification is essentially different from that of modifying data.
Second-level cache design ideas