Version-based data update method, device, electronic device and storage medium
A data update and data technology, applied in database update, electronic digital data processing, structured data retrieval, etc., can solve problems such as users seeing and nickname information not being updated in time, and achieve the effect of avoiding data inconsistency
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment approach 1
[0034] Implementation mode 1: update the cache (cache) immediately after updating the database (db).
[0035] This implementation mode 1 can refresh the cache at the fastest speed, but in some high concurrency scenarios, such as figure 1As shown in the figure, the multiple operations of writing to the cache may be out of order due to network out-of-sequence or different processing time, etc., resulting in a problem of out-of-order and overwriting each other, resulting in data inconsistency.
[0036] Based on this, you can consider using methods such as memory locks / distribution locks to serialize operations. For example, operations such as write db (write database) and update cache (update cache) can be included in the scope of a lock in the application (app) code, so that the above-mentioned coverage problem will not occur. But the granularity of this lock is relatively large, because it includes several round-trips of network transmission and the time for database persisten...
Embodiment approach 2
[0037] Implementation 2: delete the cache after updating the db, this implementation is also called cache aside.
[0038] Embodiment 2 is relatively balanced, but in special scenarios, such as figure 2 As shown, there is also a situation where the cache is overwritten by the old version of the data, resulting in data inconsistency.
[0039] Based on this, it can be considered to add an expiration time to the cache, relying on the automatic expiration of the cache, so as to reduce the inconsistent time, but this implementation method does not fundamentally solve the problem.
Embodiment approach 3
[0040] Implementation mode 3: Return directly after updating the cache, and refresh to db asynchronously by an independent worker program. This implementation mode is also called write behind.
[0041] This implementation mode 3 can achieve fast writing speed and high throughput, but this implementation mode may also have long-term inconsistency between cache and db data, and there is a risk of data loss in some special scenarios , For example, before the worker program is refreshed to the db, the cache server is down, etc. And this implementation method also needs a set of track mechanism to identify which caches have been modified, and only refresh the modified cache data when refreshing the db, or only refresh to when some caches need to fail due to insufficient space. db. It can be seen that the overall implementation complexity of this embodiment is relatively high.
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


