Version update method and device, computer readable storage medium, and processor

By recording version numbers in the database and memory cache and synchronous updates, the problem of inconsistency between database and cache data in the existing technology is solved, and efficient cache synchronization and flexible expansion capabilities are achieved.

CN112988708BActive Publication Date: 2024-11-29中国邮政储蓄银行股份有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110267621.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-11
Publication Date
2024-11-29
Estimated Expiration
2041-03-11

Smart Images

  • Figure CN112988708B_ABST
    Figure CN112988708B_ABST
Patent Text Reader

Abstract

The present invention discloses a version update method and device, a computer-readable storage medium, and a processor. The update method includes: obtaining all business table data recorded in a preset database, wherein a business detail table and a business summary table are pre-set in the preset database, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number, and then based on all business table data, the version numbers in the business detail table and the business summary table are updated to obtain an update result, and then based on the update result, it is determined whether the version number in the business summary table is consistent with the total version number recorded on the memory cache end, and if the version number in the business summary table is inconsistent with the total version number recorded on the memory cache end, the total version number of the memory cache end is updated based on the version number in the business summary table. The present invention solves the technical problem in the related art that the data in the database and the cache are updated separately, resulting in inconsistent data between the two.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data update technology, and in particular to a version update method and device, a computer-readable storage medium, and a processor. Background Art

[0002] At present, we have entered the information age. How to keep the data in the memory cache synchronized with the data in the database is a problem that all memory cache technologies must solve. In business systems, the forms of database access can be divided into read access and write access according to whether the data is changed. Among them, the number of read accesses is significantly higher than the number of write accesses.

[0003] In the related art, in order to make the database of the software system bear greater performance pressure, an additional layer of memory cache (such as Redis, etc.) is adopted, so that a large number of read requests are completed by the memory cache. In this way, the database only processes write requests, which can greatly reduce the pressure on the database. In addition, the memory cache data should be consistent with the database data to be available. The existing update strategies to ensure consistency are: 1. Update the database first, then update the cache; 2. Delete the cache first, then update the database; 3. Update the database first, then delete the cache. There are multiple disadvantages in these three strategies: Disadvantage 1, it may cause inconsistency problems in the data of the two, for example, update the database first, and then update the cache. If the first step of updating the database is successful, and the second step of updating the cache fails, there is inconsistency between the two. This inconsistency will cause data confusion, business logic depends on data judgment errors, and this cache inconsistency is usually difficult to find in the business system.

[0004] Disadvantage 2: Due to the high coupling with the business system, the code of the business system is highly invasive. These three strategies usually develop responsive update cache code in the business system. This mechanism of direct coupling in the business system makes the business program too complicated and scattered in different business functions, which is difficult to fully cover during testing and easily leaves quality risks.

[0005] Disadvantage 3: It is difficult to adapt to the horizontal expansion scenario of the cache server. These three strategies usually require that the cache server is a single machine. If the cache server is multiple machines, and the number of machines can be dynamically expanded / contracted at any time, this will make the business system code for the above cache updates more complicated, and a large number of parameters and codes need to be maintained to support the real-time dynamic expansion of the cache server. At the same time, it is also difficult to ensure the consistency of multiple cache servers (for example, when there is a short jitter in the network of one of the cache servers).

[0006] Disadvantage 4: Disaster recovery switching and other issues may cause a large number of cache misses for a long time. The production environment usually adopts a multi-center and multi-server disaster recovery deployment architecture. When a disaster recovery switch occurs, the new cache server will take over the original failed cache server. Since the database in the memory of the new cache server is in an initial clean state, when the business system uses the memory cache at this time, a large number of cache data misses, and a large number of misses continue for a long time, which significantly reduces the performance of the business system. When the business system finds that the data cannot be hit, it loads the data from the database into the cache, and only when the business system finds a miss, it will load it passively afterwards. It is impossible to achieve early, active, and batch efficient loading to avoid a large number of cache misses for a long time.

[0007] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0008] The embodiments of the present invention provide a version update method and device, a computer-readable storage medium, and a processor to at least solve the technical problem in the related art that the data in the database and the cache are updated separately, resulting in inconsistency between the two data.

[0009] According to one aspect of an embodiment of the present invention, a version update method is provided, which is applied to a memory cache end of a business system, and the memory cache end is connected to a preset database, comprising: obtaining all business table data recorded in the preset database, wherein a business detail table and a business summary table are pre-set in the preset database, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number; based on all the business table data, updating the version numbers in the business detail table and the business summary table to obtain an update result; based on the update result, determining whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end; if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, updating the total version number of the memory cache end based on the version number in the business summary table.

[0010] Optionally, based on the data of all the business tables, the version numbers in the business detail table and the business summary table are updated to obtain the update result, comprising: based on the data of all the business tables, analyzing whether a new business table appears in the preset database; if a new business table appears in the preset database, adding a new version number in the business detail table, wherein the added new version number corresponds to the new business table; if the new version number is higher than the version number recorded in the business summary table, updating the version number in the business summary table to the new version number to obtain the update result.

[0011] Optionally, after determining whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end, the version update method also includes: if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, using a preset control thread to query the business details table to obtain the new business table corresponding to the new version number; reading the data stored in the new business table; and updating the data in the new business table to the memory cache end.

[0012] Optionally, based on the update result, the step of determining whether the version number in the business master table is consistent with the total version number recorded in the memory cache end includes: using a preset control thread to compare whether the version number in the business master table is consistent with the total version number recorded in the memory cache end; if the version number in the business master table is consistent with the total version number recorded in the memory cache end, continuing to perform the version refresh operation according to the version update strategy.

[0013] Optionally, the memory cache records a total version number and a business detail version number, wherein the total version number is consistent with the latest version number of the business summary table record in the preset database, and the business detail version number is consistent with the business version number corresponding to each business table recorded in the business detail table in the preset database.

[0014] Optionally, after updating the total version number of the memory cache end based on the version number in the business summary table, the version update method also includes: using a preset control thread to update the total version number of the memory cache end based on the version number in the business summary table; using a thread control pool to update the total version number of the memory cache end based on the version number recorded in the business details table.

[0015] Optionally, the version update method further includes: determining whether the memory cache end enters a disaster recovery switching mode; if the memory cache end enters the disaster recovery switching mode, automatically loading all data currently cached by the memory cache end to the new server using a preset control thread.

[0016] According to another aspect of an embodiment of the present invention, a version update device is also provided, which is applied to a memory cache end of a business system, and the memory cache end is connected to a preset database, including: an acquisition unit, used to acquire all business table data recorded in the preset database, wherein a business detail table and a business summary table are pre-set in the preset database, and the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number; a first update unit, used to update the version numbers in the business detail table and the business summary table based on all the business table data to obtain an update result; a judgment unit, used to judge whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end based on the update result; and a second update unit, used to update the total version number of the memory cache end based on the version number in the business summary table if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end.

[0017] Optionally, the first update unit includes: a first analysis module, used to analyze whether a new business table appears in the preset database based on all the business table data; a first adding module, used to add a new version number to the business details table if a new business table appears in the preset database, wherein the added new version number corresponds to the new business table; a first update module, used to update the version number in the business summary table to the new version number if the new version number is higher than the version number recorded in the business summary table, to obtain the update result.

[0018] Optionally, the version update device also includes: a first output module, which is used to, after determining whether the version number in the business general table is consistent with the total version number recorded in the memory cache end, if the version number in the business general table is inconsistent with the total version number recorded in the memory cache end, use a preset control thread to query the business details table to obtain the new business table corresponding to the new version number; a first reading module, which is used to read the data stored in the new business table; and a second update module, which is used to update the data in the new business table to the memory cache end.

[0019] Optionally, the judgment unit includes: a first comparison module, used to use a preset control thread to compare whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end; a first execution module, used to continue to perform the version refresh operation according to the version update strategy if the version number in the business summary table is consistent with the total version number recorded in the memory cache end.

[0020] Optionally, the memory cache records a total version number and a business detail version number, wherein the total version number is consistent with the latest version number of the business summary table record in the preset database, and the business detail version number is consistent with the business version number corresponding to each business table recorded in the business detail table in the preset database.

[0021] Optionally, the version update device also includes: a third update module, which is used to use a preset control thread to update the total version number of the memory cache end based on the version number in the business master table after the total version number of the memory cache end is updated based on the version number in the business master table; and a fourth update module, which is used to use a thread control pool to update the total version number of the memory cache end based on the version number recorded in the business detail table.

[0022] Optionally, the version update device also includes: a first judgment module, used to determine whether the memory cache end enters the disaster recovery switching mode; a first loading module, used to use a preset control thread to automatically load all data currently cached by the memory cache end to the new server if the memory cache end enters the disaster recovery switching mode.

[0023] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, characterized in that the storage medium is used to store a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located controls the device to execute the above-mentioned version update method.

[0024] According to another aspect of an embodiment of the present invention, a processor is further provided, characterized in that the processor is used to run a program, wherein the above-mentioned version update method is executed when the program is running.

[0025] In an embodiment of the present invention, all business table data recorded in a preset database is obtained, wherein a business detail table and a business summary table are pre-set in the preset database, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number, and then based on all business table data, the version numbers in the business detail table and the business summary table are updated to obtain an update result, and then based on the update result, it is determined whether the version number in the business summary table is consistent with the total version number recorded on the memory cache end, and if the version number in the business summary table is inconsistent with the total version number recorded on the memory cache end, the total version number of the memory cache end is updated based on the version number in the business summary table. In this embodiment, a cache synchronization mechanism based on version numbers is implemented, and two version tables are pre-designed in the database: the business summary table and the business detail table, and the total version number and the detail version number are also recorded in the memory cache respectively, and then synchronized updates are performed through the version number, thereby avoiding the problem of data inconsistency caused by updating data in two steps in the database and the memory cache, thereby solving the technical problem in the related technology that the data in the database and the cache are updated separately, resulting in inconsistent data between the two. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0027] Figure 1 is a flow chart of an optional version updating method according to an embodiment of the present invention;

[0028] Figure 2 is a schematic diagram of another optional version number-based memory synchronization strategy according to an embodiment of the present invention;

[0029] Figure 3 is a schematic diagram of an optional version updating device according to an embodiment of the present invention; DETAILED DESCRIPTION

[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0032] The following embodiments of the present invention can be applied to the memory cache end of various business systems, and the business systems involved include but are not limited to: banking business systems, personnel management business systems, logistics management business systems, etc.

[0033] Optionally, in the following embodiments of the present invention, an atomic self-increment mechanism for version numbers and a real-time capture mechanism for database changes (i.e., triggers) are used to synchronously update data through independent threads. This not only avoids the problem of inconsistency between data in the database and data in the memory cache, but also allows for unification of development and testing without relying on a specific business system, thus avoiding the problem of missed tests in decentralized development. At the same time, centralized maintenance is possible, which improves business system reliability and reduces maintenance difficulty. Cache servers can also be flexibly added or deleted, as well as disaster recovery switching scenarios can be automatically used.

[0034] The present invention is described in detail below in conjunction with various embodiments.

[0035] Embodiment 1

[0036] According to an embodiment of the present invention, a version update method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0037] Figure 1 is a flow chart of an optional version update method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0038] Step S102, obtaining all business table data recorded in a preset database, wherein the preset database is pre-set with a business detail table and a business summary table, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number;

[0039] Step S104, based on all business table data, update the version numbers in the business detail table and the business general table to obtain an update result;

[0040] Step S106, based on the update result, determine whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end;

[0041] Step S108: If the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, the total version number of the memory cache end is updated based on the version number in the business summary table.

[0042] Through the above steps, all business table data recorded in the preset database can be obtained, wherein the preset database is pre-set with a business detail table and a business summary table, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number, and then based on all business table data, the version numbers in the business detail table and the business summary table are updated to obtain the update result, and then based on the update result, it is determined whether the version number in the business summary table is consistent with the total version number recorded on the memory cache end, if the version number in the business summary table is inconsistent with the total version number recorded on the memory cache end, then the total version number of the memory cache end is updated based on the version number in the business summary table. In this embodiment, based on the cache synchronization mechanism of the version number, two version tables are pre-designed in the database: the business summary table and the business detail table, and the total version number and the detail version number are also recorded in the memory cache respectively, and then synchronized and updated through the version number, avoiding the problem of data inconsistency caused by updating the data in the database and the memory cache in two steps, thereby solving the technical problem of data inconsistency caused by separate updates of the data in the database and the cache in the related technology.

[0043] This embodiment uses the version number atomic self-increment mechanism and the database change real-time capture mechanism (ie, trigger) to synchronously update data through independent threads when implementing the cache data synchronization strategy based on the version number.

[0044] The embodiments of the present invention are described in detail below in combination with the above-mentioned implementation steps.

[0045] The embodiment of the present invention is applied to a memory cache end of a business system, wherein the memory cache end is connected to a preset database.

[0046] Step S102, obtaining all business table data recorded in a preset database, wherein a business detail table and a business summary table are pre-set in the preset database, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number.

[0047] In this embodiment, the database includes but is not limited to: Oracle database, SQL Server database, DB2 database, etc. In this embodiment, two version tables are designed in the database, including: a business summary table and a business detail table, wherein the business summary table records the highest version number in the entire database, which is equal to the version number of all detail tables, and usually has only one record, which can make the refresh comparison more efficient and the performance better. The business detail table usually has multiple records, each record corresponds to a version number and data to be synchronized, and the initial value of all version numbers is set to 0.

[0048] Similarly, in this embodiment, the total version number and the detailed version number are recorded separately at the memory cache end. The total version number represents the version number of the global bus in the current memory cache, and the detailed version number is the specific version number of each type of cache data (usually one business table corresponds to one type of cache data), and the initial value of all version numbers is 0.

[0049] Step S104: based on all the business table data, update the version numbers in the business detail table and the business general table to obtain an update result.

[0050] Optionally, based on all business table data, the version numbers in the business detail table and the business summary table are updated to obtain the update result, including: based on all business table data, analyzing whether a new business table appears in the preset database; if a new business table appears in the preset database, adding a new version number to the business detail table, wherein the added new version number corresponds to the new business table; if the new version number is higher than the version number recorded in the business summary table, updating the version number in the business summary table to the new version number to obtain the update result.

[0051] In this embodiment, if the business table data in the database is changed, the version number of the business table in the business details table in the database is increased in real time after each change through the database trigger mechanism. When adding a new version number in the business details table, the version number atomic self-increment mechanism is used. The version number uses atomic self-increment. If the updated business detail version number is higher than the version number of the business summary table, the version number of the business summary table is also updated to the highest version number.

[0052] Step S106: Based on the update result, determine whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end.

[0053] Optionally, after determining whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end, the version update method also includes: if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, using a preset control thread to query the business details table to obtain a new business table corresponding to the new version number; reading the data stored in the new business table; and updating the data in the new business table to the memory cache end.

[0054] In this embodiment, the total service version number in the database and the total version number in the memory cache can be compared by an independent thread to see if they are consistent, wherein the independent thread can be scheduled by the database or scanned regularly. If the version numbers are consistent, no action is required and the refresh is continued; if the version numbers are inconsistent, the difference is determined. Therefore, in the case of consistent version numbers, only the total version number needs to be compared, which avoids the performance loss caused by a large number of scans from the database, simplifies the comparison object, and improves the refresh efficiency.

[0055] In this embodiment, if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache, the independent thread finds the corresponding database from the business details table of the database based on the difference, and caches the range of the version number difference into the memory, that is, reads out the data in the memory cache that lags behind the version number range of the database, and then updates the latest database to the memory cache.

[0056] Optionally, based on the update result, the step of determining whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end includes: using a preset control thread to compare whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end; if the version number in the business summary table is consistent with the total version number recorded in the memory cache end, continue to perform the version refresh operation according to the version update policy.

[0057] In this embodiment, if the total version numbers are consistent, the refresh operation is maintained without any other comparisons. This can avoid performance loss caused by large-scale scanning from the database, simplify the comparison objects, and improve the refresh efficiency.

[0058] Step S108: If the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, the total version number of the memory cache end is updated based on the version number in the business summary table.

[0059] This strategy decides whether to synchronize the memory cache data after comparing multiple version numbers, avoiding data inconsistency problems between the database and the memory cache. In this strategy, even if the synchronization update fails occasionally due to abnormal factors such as network jitter, it will continue to update in the next comparison version number update. Therefore, this strategy has the ability to automatically discover data anomalies and repair them.

[0060] In this embodiment, after the memory cache is updated, the detail version number and the total version number in the memory cache are updated, wherein the total version number is equal to the version numbers of all the details.

[0061] In an optional implementation manner of the present invention, a total version number and a business detail version number are recorded in a memory cache end, wherein the total version number is consistent with the latest version number of the business summary table record in a preset database, and the business detail version number is consistent with the business version number corresponding to each business table recorded in the business detail table in the preset database.

[0062] That is, in the memory cache, the latest total version number and detailed version number in the memory environment are also maintained.

[0063] In another optional implementation of the present invention, after updating the total version number of the memory cache end based on the version number in the business summary table, the version update method also includes: using a preset control thread to update the total version number of the memory cache end based on the version number in the business summary table; using a thread control pool to update the total version number of the memory cache end based on the version number recorded in the business detail table.

[0064] In this implementation, by updating data through preset control threads and thread control pools, data updates can be made independent of specific business systems and non-invasive to business systems. Synchronous update actions are completed by independent threads or thread pools, and unified development and testing are performed to avoid scattered development and missed tests. At the same time, centralized maintenance is possible, which improves business system reliability and reduces maintenance difficulty. In addition, this mechanism can also be used in multiple business systems as a general mechanism, and has reusable promotion value. This solves the problem of high coupling with business systems and high code intrusion into business systems in the prior art.

[0065] At the same time, this implementation has flexible cache server horizontal expansion capabilities. If one or more cache servers need to be added, you only need to start a new refresh mechanism (thread or multi-thread). According to this synchronous update strategy, the new cache server will be automatically loaded with the latest data, and this memory cache loading is not loaded one by one, but in batches, which greatly improves the efficiency of the memory synchronous update strategy.

[0066] Alternatively, the version update method further includes: determining whether the memory cache end enters a disaster recovery switching mode; if the memory cache end enters a disaster recovery switching mode, automatically loading all data currently cached by the memory cache end to the new server using a preset control thread.

[0067] In this embodiment, the disaster recovery switching scenario can be automatically used. Since the decision on whether to update the cache is based on the difference in version numbers, in a multi-center and multi-node disaster recovery deployment structure, when a disaster recovery switch occurs, no manual intervention and operation is required. The independent thread will automatically load all cached data to a new server (that is, the version number is initially 0) based on the version number difference. Moreover, this memory cache loading is not loaded one by one, but in batches, which greatly improves the efficiency of the memory synchronization update strategy. In this way, the memory of the new server after the disaster recovery switch can be synchronized with the latest data in a shorter time, avoiding the problem of long-term and large-scale memory hits.

[0068] Figure 2 is a schematic diagram of another optional memory synchronization strategy based on version number according to an embodiment of the present invention, such as Figure 2 As shown in the figure, the cache synchronization mechanism based on the version number is designed to define an auto-increment number as the version number. Two version tables are designed in the database: the general table and the detailed table. The general table records the highest version number in the entire database, which is equal to max (the version number of all details). Usually there is only one record, which makes the refresh comparison more efficient and has better performance. The detailed table usually has multiple records, each of which corresponds to a version number and data to be synchronized. The initial value of all version numbers is 0. In the memory cache, the total version number and the detailed version number are also recorded separately. The total version number represents the version number of the global bus in the current memory cache, and the detailed version number is the specific version number of each type of cached data (usually one business table corresponds to one type of cached data). The initial value of all version numbers is 0.

[0069] The specific memory synchronization strategy is as follows:

[0070] 1. If the business table data in the database is changed, the database trigger mechanism will increase the version number of the business table in the detail table in the database in real time after each change. The version number is atomically incremented. If the updated detail version number is higher than the master table version number, the master table version will also be updated to the highest version number.

[0071] 2. In the memory cache, the latest total version number and detailed version of the memory environment are also maintained.

[0072] 3. Use an independent thread (can be scheduled by database or scanned regularly) to compare the total version number in the database with the total version number in the memory cache. If they are consistent, no action is taken and the refresh continues. If the version numbers are inconsistent, the differences are determined. Therefore, when the version numbers are consistent, only the total version numbers need to be compared, thus avoiding the performance loss caused by large-scale scanning from the database, simplifying the comparison objects, and improving the refresh efficiency.

[0073] 4. Then the independent thread finds the corresponding database from the detailed table in the database according to the difference, and caches the range of the version number difference into the memory, that is, reads out the data in the memory cache that lags behind the version number range of the database, and then updates the latest database to the memory cache.

[0074] 5. After the memory cache is updated, update the detail version number and total version number in the memory cache. The total version number is equal to max (the version number of all details).

[0075] The above version number-based memory cache synchronization update strategy has the following advantages:

[0076] 1. This strategy compares multiple version numbers to decide whether to synchronize the memory cache data, avoiding the inconsistency problem caused by writing in two steps in the existing technology. In this mechanism, even if the synchronization update fails occasionally due to abnormal factors such as network jitter, the update will continue in the next comparison version number update, so this mechanism has the ability to automatically discover data anomalies and repair them.

[0077] 2. This strategy is independent and does not depend on a specific business system. It is non-invasive to the business system. Synchronous update actions are completed by independent threads or thread pools. Unified development and testing avoid decentralized development and missed tests. At the same time, it can be centrally maintained, which improves business system reliability and reduces maintenance difficulty. As a general strategy, this strategy can be used in multiple business systems and has reusable promotion value.

[0078] 3. This strategy has flexible cache server horizontal expansion capabilities. If you need to add one or more cache servers, you only need to start a new refresh mechanism (thread or multi-thread). According to this synchronous update strategy, the new cache server will be automatically loaded with the latest data. Moreover, this memory cache loading is not loaded one by one, but in batches, which greatly improves the efficiency of the memory synchronous update strategy.

[0079] 4. This strategy can automatically use the disaster recovery switching scenario. Since it is based on the difference in version numbers to decide whether to update the cache, in a multi-center and multi-node disaster recovery deployment structure, when a disaster recovery switch occurs, there is no need for manual intervention and operation. Independent threads will automatically load all cache data to a new server (the version number is initially 0) based on the version number difference. Moreover, this memory cache loading is not loaded one by one, but in batches, which greatly improves the efficiency of the memory synchronization update strategy. In this way, the memory of the new server after the disaster recovery switch can be synchronized with the latest data in a shorter time, avoiding the problem of long-term and large-scale memory failures.

[0080] The present invention is described below in conjunction with another optional embodiment.

[0081] Embodiment 2

[0082] The embodiment of the present invention provides a version updating device, and each implementation unit included in the updating device corresponds to each implementation step in the above-mentioned embodiment 1.

[0083] Figure 3 is a schematic diagram of an optional version updating device according to an embodiment of the present invention, such as Figure 3 As shown, the version update device includes: an acquisition unit 30, a first update unit 32, a judgment unit 34, and a second update unit 36, wherein:

[0084] The acquisition unit 30 is used to acquire all business table data recorded in a preset database, wherein a business detail table and a business summary table are pre-set in the preset database, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number;

[0085] A first updating unit 32 is used to update the version numbers in the business detail table and the business general table based on all business table data to obtain an update result;

[0086] A judging unit 34, configured to judge whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end based on the update result;

[0087] The second updating unit 36 ​​is configured to update the total version number of the memory cache end based on the version number in the business summary table if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end.

[0088] The above-mentioned version updating device can obtain all business table data recorded in the preset database through the acquisition unit 30, wherein the preset database is pre-set with a business detail table and a business summary table, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number, and then based on all the business table data, the version numbers in the business detail table and the business summary table are updated through the first update unit 32 to obtain an update result, and then based on the update result, the judgment unit 34 is used to judge whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end. If the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, the total version number of the memory cache end is updated through the second update unit 36 ​​based on the version number in the business summary table. In this embodiment, a cache synchronization mechanism based on the version number is designed and defined, and a self-incrementing number is defined as the version number. Two version tables are pre-designed in the database: a business summary table and a business detail table. The total version number and the detail version number are also recorded in the memory cache, respectively. The versions are then updated synchronously, thereby avoiding the problem of data inconsistency caused by updating the database and the memory cache in two steps. This solves the technical problem in the related technology of separate updating of the data in the database and the cache, resulting in data inconsistency between the two.

[0089] Optionally, the first update unit includes: a first analysis module, used to analyze whether a new business table appears in the preset database based on all business table data; a first addition module, used to add a new version number to the business details table if a new business table appears in the preset database, wherein the added new version number corresponds to the new business table; a first update module, used to update the version number in the business summary table to the new version number if the new version number is higher than the version number recorded in the business summary table, to obtain an update result.

[0090] Optionally, the version update device also includes: a first output module, which is used to, after determining whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end, if the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, use a preset control thread to query the business details table to obtain a new business table corresponding to the new version number; a first reading module, which is used to read the data stored in the new business table; and a second update module, which is used to update the data in the new business table to the memory cache end.

[0091] Optionally, the judgment unit includes: a first comparison module, used to use a preset control thread to compare whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end; a first execution module, used to continue to perform the version refresh operation according to the version update strategy if the version number in the business summary table is consistent with the total version number recorded in the memory cache end.

[0092] Optionally, the memory cache records a total version number and a business detail version number, wherein the total version number is consistent with the latest version number of the business summary table record in the preset database, and the business detail version number is consistent with the business version number corresponding to each business table recorded in the business detail table in the preset database.

[0093] Optionally, the version update device also includes: a third update module, which is used to use a preset control thread to update the total version number of the memory cache end based on the version number in the business general table after the total version number of the memory cache end is updated based on the version number in the business general table; a fourth update module, which is used to use a thread control pool to update the total version number of the memory cache end based on the version number recorded in the business detail table.

[0094] Optionally, the version update device also includes: a first judgment module, used to judge whether the memory cache end enters the disaster recovery switching mode; a first loading module, used to use a preset control thread to automatically load all data currently cached by the memory cache end to the new server if the memory cache end enters the disaster recovery switching mode.

[0095] The above-mentioned version update device may also include a processor and a memory. The above-mentioned acquisition unit 30, first update unit 32, judgment unit 34, second update unit 36, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.

[0096] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the kernel parameters are adjusted to determine whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end. If the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, the total version number of the memory cache end is updated based on the version number in the business summary table.

[0097] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.

[0098] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, characterized in that the storage medium is used to store a computer program, wherein the computer program, when executed by a processor, controls the device where the computer-readable storage medium is located to execute the above-mentioned version update method.

[0099] According to another aspect of an embodiment of the present invention, a processor is further provided, wherein the processor is used to run a program, wherein the above-mentioned version updating method is executed when the program is running.

[0100] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: obtaining all business table data recorded in a preset database, and then updating the version numbers in the business detail table and the business summary table based on all the business table data to obtain an update result, and then based on the update result, determining whether the version number in the business summary table is consistent with the total version number recorded on the memory cache end; if the version number in the business summary table is inconsistent with the total version number recorded on the memory cache end, then updating the total version number of the memory cache end based on the version number in the business summary table.

[0101] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0102] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0103] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0104] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0105] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0106] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0107] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A version update method, characterized in that: A memory cache end applied to a business system, the memory cache end being connected to a preset database, including: Acquire all business table data recorded in the preset database, wherein the preset database is pre-set with a business detail table and a business summary table, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number; Based on the data of all the business tables, the version numbers in the business detail table and the business general table are updated to obtain an update result, including: based on the data of all the business tables, analyzing whether a new business table appears in the preset database; if a new business table appears in the preset database, adding a new version number in the business detail table using a version number atomic self-increment mechanism, wherein the added new version number corresponds to the new business table; if the new version number is higher than the version number recorded in the business general table, updating the version number in the business general table to the new version number to obtain the update result; Based on the update result, determining whether the version number in the business summary table is consistent with the total version number recorded on the memory cache end; If the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, the total version number of the memory cache end is updated based on the version number in the business summary table; the step of judging whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end includes: using a preset control thread to compare whether the version number in the business summary table is consistent with the total version number recorded in the memory cache end; if the version number in the business summary table is consistent with the total version number recorded in the memory cache end, continuing to perform the version refresh operation according to the version update strategy; the version update method also includes: judging whether the memory cache end enters the disaster recovery switching mode; if the memory cache end enters the disaster recovery switching mode, using a preset control thread to automatically load all the data currently cached by the memory cache end to the new server.

2. The method according to claim 1, characterized in that After determining whether the version number in the service summary table is consistent with the total version number recorded in the memory cache end, the version update method further includes: If the version number in the business summary table is inconsistent with the total version number recorded in the memory cache end, a preset control thread is used to query the business detail table to obtain the new business table corresponding to the new version number; Read the data stored in the new business table; The data in the new service table is updated to the memory cache end.

3. The method according to claim 1, characterized in that The memory cache end records a total version number and a business detail version number, wherein the total version number is consistent with the latest version number of the business summary table record in the preset database, and the business detail version number is consistent with the business version number corresponding to each business table recorded in the business detail table in the preset database.

4. The method according to claim 3, characterized in that After updating the total version number of the memory cache end based on the version number in the business summary table, the version update method further includes: Using a preset control thread, updating the total version number of the memory cache end based on the version number in the business summary table; A thread control pool is adopted to update the total version number of the memory cache end based on the version number recorded in the business details table.

5. A version updating device, characterized in that: A memory cache end applied to a business system, the memory cache end being connected to a preset database, including: An acquisition unit, used to acquire all business table data recorded in the preset database, wherein the preset database is pre-set with a business detail table and a business summary table, the business detail table is used to record the business version number corresponding to each business table, and the business summary table records the latest version number; A first updating unit is used to update the version numbers in the business detail table and the business general table based on the data of all the business tables to obtain an update result; the first updating unit includes: a first analyzing module, used to analyze whether a new business table appears in the preset database based on the data of all the business tables; a first adding module, used to add a new version number in the business detail table using a version number atomic self-increment mechanism if a new business table appears in the preset database, wherein the added new version number corresponds to the new business table; a first updating module, used to update the version number in the business general table to the new version number if the new version number is higher than the version number recorded in the business general table to obtain the update result; A judging unit, configured to judge, based on the update result, whether the version number in the service summary table is consistent with the total version number recorded in the memory cache end; A second update unit is used to update the total version number of the memory cache end based on the version number in the business master table if the version number in the business master table is inconsistent with the total version number recorded in the memory cache end; a first comparison module is used to use a preset control thread to compare whether the version number in the business master table is consistent with the total version number recorded in the memory cache end; a first execution module is used to continue to perform a version refresh operation according to a version update strategy if the version number in the business master table is consistent with the total version number recorded in the memory cache end; the device also includes: a first judgment module, used to judge whether the memory cache end enters a disaster recovery switching mode; a first loading module is used to use a preset control thread to automatically load all data currently cached by the memory cache end to the new server if the memory cache end enters the disaster recovery switching mode.

6. A computer-readable storage medium, characterized in that: The storage medium is used to store a computer program, wherein the computer program, when executed by a processor, controls the device where the computer-readable storage medium is located to execute the version update method according to any one of claims 1 to 4.

7. A processor, characterized in that: The processor is used to run a program, wherein the program executes the version update method described in any one of claims 1 to 4 when running.

Citation Information

Patent Citations

  • Parameter increment loading method and device, computer equipment and storage medium

    CN111475518A