Dual-channel data consistency keeping method, storage medium and electronic equipment

By first update in the cache in the business service system and obtaining the value of the changed field from the database at the second update time T2 for secondary update, the problem of inconsistent values ​​between the database and the same field in the cache is solved, and data consistency and credibility are improved.

CN120045572APending Publication Date: 2025-05-27MOBILE TECH COMPANY CHINA TRAVELSKY HLDG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510253924.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-05
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

In the business service system, due to the different update mechanisms of the database and cache, the values ​​of the same field in the database and cache are inconsistent, which reduces the trustworthiness of the data.

Method used

By first updating the value of the change field in the cache, and obtaining the value of the change field from the database for a secondary update time T2 at the second update time T2, ensuring the consistency of the data in the database and in the cache.

Benefits of technology

It realizes consistency between the database and cached business data, improves the credibility of data, and reduces the backlog of database update events.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045572A_ABST
    Figure CN120045572A_ABST
Patent Text Reader

Abstract

The invention relates to the field of data updating, in particular to a dual-channel data consistency keeping method, a storage medium and electronic equipment. Comprising the step of updating a field value corresponding to a changed field in a current cache for the first time according to change content included in cache field change information. And when the secondary updating time is up, respectively acquiring a field value corresponding to each change field from the corresponding database, and performing secondary updating on the change field in the current cache. In the application, when the cache field change information is obtained, the corresponding content in the current cache is directly updated firstly, so that the data obtained by the business side is ensured to be more accurate and timely business data. Besides, a certain waiting time is set to wait for the database to complete processing of the overstocked update events so as to obtain the completely updated business data, so that the consistency of the data in the two data storage channels can be ensured, and the credibility of the data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In the existing business service system, each business party accessing the system usually needs to obtain different field data from the system to complete corresponding business functions. At the same time, different business fields are usually stored in different databases. In order to obtain the corresponding business field content, the business party usually needs to query the corresponding database or the cache for temporarily storing data. Usually, the cache has a faster query speed. Therefore, in order to improve the query efficiency, after receiving a business request, the corresponding business data will be preferentially queried from the cache. In the case where the corresponding data cannot be obtained from the cache, the corresponding database will be queried.

[0003] In actual business operations, with the change of the actual business situation, it is necessary to frequently perform operations of adding, deleting, modifying, and querying the content of the corresponding business fields in the database or cache. Especially in some service systems with more business functions, usually during business operations, there are a large number of operations for updating the corresponding business fields caused by business change events. However, due to the different mechanisms for updating data in different storage channels (i.e., the database and the cache), the database and the cache respectively have different update efficiencies, resulting in inconsistent field values corresponding to the same field in the two storage channels of the database and the cache, thereby reducing the credibility of the data. Summary of the Invention

[0004] In view of the above technical problems, the technical solution adopted by the present invention is as follows:

[0005] According to one aspect of the present invention, there is provided a method for maintaining dual-channel data consistency, the method comprising the following steps:

[0006] According to the change content included in the cache field change information, the field value corresponding to the changed field in the current cache is first updated. The cache field change information is generated by a business change event, and the business change event is a change event generated after the business initialization event occurs. The change content includes the changed field and the changed field value.

[0007] When the secondary update time T2 is reached, according to the changed fields included in the cache field change information, the field values corresponding to each changed field are respectively obtained from the corresponding database, and the field values corresponding to the changed fields in the current cache are secondarily updated. T2 meets the following conditions: T2 = T1 + t1, where T1 is the completion time of the first update, and t1 is the first preset update interval duration.

[0008] According to a second aspect of the present invention, there is provided a non-transitory computer-readable storage medium storing a computer program which, when executed by a processor, implements the above-mentioned method for maintaining dual-channel data consistency.

[0009] According to a third aspect of the present invention, there is provided an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the above-mentioned method for maintaining dual-channel data consistency.

[0010] The present invention has at least the following beneficial effects:

[0011] In this application, when cache field change information generated by a service change event is obtained, the corresponding content in the current cache is directly updated according to the changed content included in the cache field change information. Thus, the change of the corresponding service field can be realized more quickly. At the same time, since the service side usually queries the cache first when requesting data, it can be ensured that the data obtained by the service side is usually more accurate and timely service data.

[0012] In addition, since there is usually a larger amount of service data maintained in the database, more service update events will be received and more frequent data update operations are required. However, due to insufficient database performance, there will be a problem of backlog of update events. In this application, in order to ensure the consistency of all service data in the two data storage channels, after the cache is first updated with the changed data, a certain time delay is set to obtain the changed data from the database to perform a secondary update on the changed data in the cache. Thus, by setting a certain waiting time t, the database is waited to complete the backlogged update events to obtain the fully updated service data, thereby ensuring the consistency of the data in the two data storage channels and improving the credibility of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings without creative efforts based on these drawings.

[0014] Figure 1 It is a schematic connection structure diagram of the service system provided by the embodiment of the present invention;

[0015] Figure 2 It is a schematic flowchart of a data response publishing method provided by the embodiment of the present invention;

[0016] Figure 3 Schematic flowchart of a method for maintaining dual-channel data consistency provided by an embodiment of the present invention;

[0017] Figure 4 Schematic flowchart of a method for updating service fields provided by an embodiment of the present invention. Detailed implementation manners

[0018] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.

[0019] Each method disclosed in the present invention is to solve related technical problems that occur in the service system. Specifically, in this embodiment, the service system may be an integrated service system for processing flight-related service information. The system includes a data response publishing module, a cache, multiple service databases, a service dynamic event publishing module, a field mapping configuration module, and a storage update module. The communication connections between the above-mentioned modules are shown as Figure 1 shown. Each service database stores and maintains service field data required for each service. Multiple service databases are all communicatively connected to the cache. Thus, during the operation of the service, the required service data can be temporarily stored in the cache to improve the query and acquisition speed of the service party. The data response publishing module is communicatively connected to the cache and multiple service databases respectively, and is used to respond to the request of the service party to obtain the corresponding service data and publish it. The service dynamic event publishing module is communicatively connected to the cache and multiple service databases respectively through the storage update module, and is used to generate update information for the cache and service databases according to the operation and change content of the service. The field mapping configuration module is provided with a field mapping information table, and the field mapping information table is maintained and updated according to the received change information of the field mapping content. The service dynamic event publishing module is communicatively connected to the data response publishing module, and the field mapping configuration module is also communicatively connected to the data response publishing module, and is used to provide support for related functions that need to rely on the field mapping information table, that is, to provide the latest field mapping information. The storage update module is used to update the data in the cache and multiple service databases to keep the data in the two storage channels as consistent as possible.

[0020] As a possible embodiment of the present invention, as Figure 2 shown, a data response publishing method is provided. This method is mainly executed by the data response publishing module. Specifically, the data response publishing method includes the following steps:

[0021] S100: Determine the operation type corresponding to the request ID according to the generation source type corresponding to the request ID. The operation types include business requests and data updates.

[0022] In this embodiment, a unique request ID will be configured for each business party in advance to obtain the corresponding business fields. Each business party corresponds to a sub-business in the entire business. For example, business party A only corresponds to the boarding pass information sub-business in a complete flight information business. Since, in actual use, the business fields used by various sub-businesses are usually fixed. For example, in the sub-business corresponding to the flight boarding pass, the main business fields it requires basically include: the passenger's name, the date of boarding, the destination, the departure place, the boarding time, the seat number, and the boarding gate and other business fields. Therefore, in this application, by setting up a field mapping information table, the mapping relationship between the request ID and the corresponding business fields can be fixed.

[0023] In addition, in this embodiment, in order to enable the business requests generated during the entire flight business operation process to quickly obtain the corresponding business fields in the cache, so in the field mapping information table, a corresponding request ID is also configured in advance for the initialization event of each flight, and the mapping relationship between all the business fields included in the flight business and this request ID is established. Thus, at the initial stage of the start of any flight business, the initialization event of the flight (i.e., the business initialization event) can be triggered, and all the business field data required in this business can be stored in the cache. Specifically, the method steps of S210 to S230 can be referred to, so as to facilitate the relevant business requests to quickly obtain the corresponding business fields from the cache later.

[0024] Based on the above configuration method of the request ID, it can be seen that in this application, not only is a corresponding request ID configured for each business party, but also a request ID is configured for the business initialization event generated in the business dynamic event publishing module. Therefore, the data response publishing module has two types of generation sources corresponding to the received request ID (business party type and business dynamic event publishing module type), and this type can be determined according to the information of the data channel for actually obtaining the request ID. Since the operations required for the two types of generation sources are also different, they need to be distinguished.

[0025] Specifically, the mapping information of the request ID and business fields corresponding to each business party and business initialization event is generated according to the following steps:

[0026] S110: Configure a corresponding unique request ID for each type of business request and preset business event respectively. The preset business events include business initialization events. The business requests and preset business events are generated by different terminals respectively.

[0027] S120: If the request ID is the ID corresponding to the service request, then select some service fields from the entire set of corresponding service fields according to the service fields required by the service request.

[0028] S130: Generate mapping configuration information between the request ID and the corresponding service fields in the field mapping information table according to the selected partial service fields.

[0029] S140: If the request ID is the ID corresponding to the preset service event, then generate mapping configuration information between the request ID and the entire set of service fields in the field mapping information table according to the corresponding entire set of service fields.

[0030] Thus, by configuring the mapping relationship between different request IDs and different ranges of service fields for different types of events, it is possible to simultaneously implement the response to the service request and the early update of the service data in the cache by identifying the request ID during later use, so as to improve the response speed of the service request.

[0031] S200: If the operation type is a service request, then obtain the first set of request fields corresponding to the request ID according to the field mapping information table. The field mapping information table includes the mapping configuration information between the request ID and the service fields obtained by the request of the request ID. The first set of request fields is a proper subset of the corresponding entire set of service fields.

[0032] S300: Obtain the field value corresponding to each request field from the current cache according to each request field included in the first set of request fields corresponding to the request ID.

[0033] S400: If the field value of any request field in the current cache is an empty set, then obtain the corresponding field value from the database to which the request field belongs.

[0034] S500: Concatenate the field values obtained from the current cache and the corresponding database to the corresponding service field positions to form response data, and publish it to the terminal corresponding to the request ID.

[0035] If the operation type is a service request, it is necessary to quickly and accurately return the field values of the service fields required by the corresponding service party. Therefore, in this application, by setting up a field mapping information table, the mapping relationship between the unique identity ID (i.e., the request ID) and the corresponding service fields is configured for each sub-service request. Thus, it is possible to configure the required service fields for each type of sub-service more precisely and flexibly. In addition, when responding to the service request of the corresponding sub-service, it is only necessary to obtain the field values of each service field from the current cache and the corresponding partial database and publish them to meet the actual usage requirements of the sub-service. For a small number of service fields that do not exist in the current cache, the corresponding service database is queried again.

[0036] Compared with the existing method of querying all business data through an interface for release response, the solution in this application can query and obtain only the partial business fields required by the request more precisely, thereby significantly reducing the number of database queries and accesses, improving the efficiency of data release response, and meeting the requirements of frequent data requests from multiple business parties in a large service system.

[0037] Meanwhile, through the control of the field mapping information table in this application, in the response data obtained by each business party, only the business fields that can be viewed within its permission scope, that is, the partial business fields configured in advance, are included, and the business parties cannot obtain all the business field data of the entire business. Thus, the security of business data can also be improved to prevent business data from being leaked or stolen.

[0038] In addition, in actual use, the usage frequencies of the various sub-businesses in a complete business are not the same. For example, there are some sub-businesses with very high usage heat, and the request frequency for the business fields corresponding to these sub-businesses is very high. On the contrary, for some sub-businesses with lower usage heat, the request frequency for the corresponding business fields is very low. In this embodiment, the business fields required by different business requests are divided by using the mapping relationship between the request ID and the business fields. Therefore, in later use, the business fields with higher usage frequencies will always be maintained in the cache, while some business fields with lower usage frequencies will be deleted. Thus, the occupation of the cache by useless data can be reduced.

[0039] S210: If the operation type is data update, then according to the field mapping information table, obtain the second request field set corresponding to the request ID. The field mapping information table includes the mapping configuration information between the request ID and the business fields requested by the request ID. The second request field set is the complete set of the corresponding business fields.

[0040] S220: According to each request field included in the second request field set corresponding to the request ID, obtain the field value corresponding to each request field from the corresponding database.

[0041] S230: Update and store the field value corresponding to each obtained request field into the current cache.

[0042] S210 to S230 can store all the business field data required in the business in the cache at the initial stage of the startup of any flight business, so that relevant business requests can quickly obtain the corresponding business fields from the cache in the later stage.

[0043] Since passengers may take multiple consecutive flights during actual trips, such as A - B - C, the flight information corresponding to the passenger will include information on the same business fields of multiple adjacent flights. In some sub - services, it is necessary to obtain the information on the same business fields of multiple adjacent flights for corresponding business calculations. For example, in the insurance sub - service, it is necessary to know the situation of the previous flight to determine whether insurance compensation should be provided for the current flight. Therefore, there is a high similarity among the sets of business fields corresponding to each flight in the service request. In the prior art, the business fields are distinguished by adding corresponding flight identifiers to different flight business fields. For example, the departure field corresponding to flight A is ACF, the departure field corresponding to flight B is BCF, and the departure field corresponding to flight C is CCF. However, the differences between these business fields are still small, and these similar fields are displayed in the form of a data sequence in the returned data. Usually, due to the close meanings, these similar fields will be concentrated, so it is very easy to make a wrong selection when the business side uses the data of the similar fields.

[0044] To solve the above - mentioned technical problems, as another possible embodiment of the present invention, S130: Generate the mapping configuration information between the request ID and the corresponding business fields in the field mapping information table according to the selected partial business fields, including:

[0045] S131: If at least two similar field sets are requested to be obtained in any type of service request, generate a scope identifier corresponding to each similar field set. The two similar field sets are the sets of business fields corresponding to two different sub - services in a type of service, and at least some of the requested fields in the two similar field sets are the same. The scope identifiers corresponding to different similar field sets are different.

[0046] S132: Generate the mapping configuration information between the request ID and the corresponding business fields in the field mapping information table according to the corresponding relationship between the request ID and each scope identifier, and the corresponding relationship between each scope identifier and the requested fields included in the corresponding similar field set.

[0047] In this embodiment, the specific configuration forms of the similar field set and the single - field set in the field mapping information table are shown in Table 1 below:

[0048] Table 1

[0049]

[0050] In Table 1 above, the first three columns can be the style of the field mapping information table in this embodiment, and the last column is only used to illustrate a possible specific style of the two field sets in this embodiment.

[0051] Correspondingly, S500: Obtain the field values from the current cache and the corresponding database, splice them to the corresponding business field positions to form response data, and publish it to the terminal corresponding to the request ID, including:

[0052] S501: If there is a mapping relationship between the request ID and at least two scope identifiers in the field mapping information table, generate a first HashMap according to the mapping information between each scope identifier and the request fields included in the corresponding similar field set. The first HashMap includes the first-level key-value pairs corresponding to each scope identifier. The key of each first-level key-value pair is the corresponding scope identifier, and the value is the second-level key-value pair corresponding to each request field included in the similar field set corresponding to the scope identifier. The key of each second-level key-value pair is a request field in the similar field set, and the value is the field value of the request field.

[0053] Specifically, a possible arrangement style of the key-value pairs of the first HashMap is as shown in Table 2 below:

[0054] Table 2

[0055]

[0056] As can be seen from Table 2 above, the first row and the fourth row are respectively the keys of the first-level key-value pairs formed by two scope identifiers. The second and third rows are the values corresponding to the first-level key Influence1. Each column in this value is a corresponding second-level key-value pair. The fifth and sixth rows are the second-level key-value pairs corresponding to Influence2.

[0057] S502: Publish the first-level HashMap to the terminal corresponding to the request ID.

[0058] In this embodiment, by configuring different scope identifiers for the similar field sets in the field mapping information table, when returning data of business field sets with high similarity, different first-level key-value pairs can be formed in the HashMap according to the scope identifiers, and then the same business fields are respectively placed in the first-level key-value pairs formed by different scope identifiers. Since the keys in the HashMap are unique, when the business side obtains the corresponding data, it needs to obtain the corresponding data in the keys formed by the corresponding scope, thereby further avoiding the misselection of data. In addition, by storing hierarchically in the HashMap, the same business fields will be distributed in different first-level key-value pairs respectively, and thus can be more clearly distinguished and displayed, further reducing the possibility of data misselection.

[0059] In addition, S130: Generate the mapping configuration information between the request ID and the corresponding business fields in the field mapping information table according to the selected partial business fields, and further includes:

[0060] S133: If a single field set is requested in any type of service request, obtain the base domain identifier. Different single field sets correspond to the same base domain identifier.

[0061] S134: Generate the mapping configuration information between the request ID and the corresponding service field in the field mapping information table according to the correspondence between the request ID, the base domain identifier, and the request fields included in the corresponding single field set. Each request field in the single field set is different.

[0062] Correspondingly, S500: Concatenate the field values obtained from the current cache and the corresponding database to the corresponding service field positions to form response data, and publish it to the terminal corresponding to the request ID, further including:

[0063] S503: If there is a mapping relationship between the request ID and the base domain identifier in the field mapping information table, generate a second HashMap according to the mapping information between the base domain identifier and the request fields included in the corresponding single field set. The second HashMap includes the first-level key-value pairs corresponding to the base domain identifier, the key of the first-level key-value pair is the base domain identifier, and the value is the second-level key-value pairs corresponding to each request field in the single field set. The key of each second-level key-value pair is each request field in the single field set, and the value is the field value of the request field.

[0064] S504: Publish the second-level HashMap to the terminal corresponding to the request ID.

[0065] In this embodiment, the style of the second-level HashMap is the same as the style shown in Table 2 above, and the specific difference is only the difference in the first-level keys. Thus, in this embodiment, different data hierarchical structures are set in the HashMap through the scope identifier, so that similar or identical service fields in adjacent flight services can be configured into the corresponding first-level key-value pairs according to the actual correspondence. Therefore, similar data can be stored in different hierarchical structures. When the business party retrieves values from the returned HashMap object later, it needs to query in the first-level key-value pairs corresponding to the corresponding scope identifier, which can increase the distinction degree of similar field sets in the returned data. In addition, in order to further increase the distinction, different scope identifiers can be set as strings with a greater difference to further improve the distinction degree to avoid misselection situations when the business party uses the data.

[0066] The method in this embodiment is mainly used to ensure the consistency of business data between the cache and multiple business databases in the service system of this application. Since the business dynamic event publishing module will generate update information for the cache and business databases respectively according to the received business change events for updating the corresponding data storage channels. However, since business databases often also store and maintain a large amount of other business data, a much larger amount of update information is usually received in business databases. At the same time, the update processing speed of the database is slower than that of the cache. Therefore, the situation of backlog of update events is likely to occur. This will lead to the inconsistency of business data corresponding to the same business field in the cache and business databases in the same business service system, and then it is easy to report data errors, resulting in a decrease in the credibility of the data, which affects the use.

[0067] To solve the above problems, as another possible embodiment of the present invention, as Figure 3 shown, a method for maintaining dual-channel data consistency is also provided. This method is mainly implemented by the storage update module. Specifically, the method for maintaining dual-channel data consistency includes the following steps:

[0068] W100: According to the change content included in the cache field change information, perform the first update on the field values corresponding to the changed fields in the current cache. The cache field change information is generated by business change events, and the business change events are change events generated after the business initialization event occurs. The change content includes the changed field and the changed field value.

[0069] The change content included in the cache field change information can be as shown in the following example. If the cache field change information is that the boarding gate of Flight A is changed to 22A, the corresponding change content can be DJK: 22A, where DJK is the changed field and 22A is the changed field value.

[0070] Before W100, the method further includes:

[0071] W110: Determine the business event type corresponding to the obtained business dynamic information according to the obtained business dynamic information.

[0072] W120: If the business event type is a field change event, generate the cache field change information and database field change information corresponding to the business dynamic information at the same time. The cache field change information is used to update the data in the current cache. The database field change information is used to update the corresponding database.

[0073] In this embodiment, the steps from W110 to W120 can be completed by the business dynamic event publishing module. The generated cache field change information and database field change information are respectively and simultaneously sent to the cache update module and the update module corresponding to the business database.

[0074] W130: If the business event type is a business initialization event, obtain the request ID corresponding to the business initialization event according to the field mapping information table. In the same business, the occurrence time of the business initialization event is earlier than the occurrence time of the field change event.

[0075] Among these business change events, it not only includes events where the content of some business fields of the business changes, but also includes the business initialization event. At the same time, since when receiving the business initialization event, it is necessary to pull the full amount of business data for cache preheating, the business dynamic event publishing module is also used to execute W130 to complete the full amount of initial data pulling work.

[0076] Of course, W130 can also be executed by the data response publishing module. Specifically, after the business dynamic event publishing module sends the information corresponding to the business initialization event to the data response publishing module, the data response publishing module can regard the information corresponding to the initialization event as a special business request and perform subsequent processing the same as the business request.

[0077] W200: When the secondary update time T2 arrives, according to the changed fields included in the cache field change information, obtain the field values corresponding to each changed field from the corresponding database respectively, and perform a secondary update on the field values corresponding to the changed fields in the current cache. T2 meets the following conditions: T2 = T1 + t1, where T1 is the completion time of the first update, and t1 is the first preset update interval duration. Preferably, t1 ∈ [5s, 60s].

[0078] In this embodiment, the duration setting of t1 is to wait for the database to process the backlogged update events, so as to ensure that the field values corresponding to the changed fields pulled from the database are the updated values as much as possible. Thus, it can also reduce the repeated modification of the cache. Therefore, the duration setting of t1 usually needs to be determined according to the speed of the database processing backlogged data in the specific usage scenario.

[0079] Specifically, the secondary update includes:

[0080] W201: If the field value corresponding to the changed field obtained from the database is the same as the field value corresponding to the changed field in the current cache, no update processing is performed on the current cache.

[0081] W202: If the field value corresponding to the changed field obtained from the database is different from the field value corresponding to the changed field in the current cache, the field value corresponding to the changed field obtained from the database is used to replace the field value corresponding to the changed field in the current cache. At the same time, an alarm message is sent to the corresponding maintenance terminal to remind the data abnormality.

[0082] In this embodiment, when an update event of a field is obtained, update information will be sent to the cache and the corresponding database at the same time. Usually, since the cached data is updated faster, the cache is updated first first. Correspondingly, when the business party obtains data, it also checks the cache first, and then checks the database if the cache does not have it. Therefore, when the business changes, the first update can ensure that the business party can obtain the latest business field data. At the same time, the information in the corresponding database is obtained after a certain delay, thereby ensuring that the field value obtained from the database is also the updated value. Then a secondary update is performed. The role of the secondary update in this embodiment is more inclined to use the data in the database to compare and verify the data in the cache. If they are consistent, no alarm is issued; if they are inconsistent, since the data in the database is usually more accurate and more reliable, the cache is updated using the data in the database and an alarm is issued.

[0083] In the usage scenario of the present application, due to the increase or change of business during actual use, the sub-business types included in the current business will change in different time periods, or the field types required in the same sub-business will change. As a result, the field mapping corresponding to the business request in the field mapping information table will change frequently, which will cause the full set of business fields determined historically to deviate from the full set of business fields actually requested at present, and thus fail to meet the changed query requirements. As a result, in the subsequent business operation process, the data corresponding to some business fields need to be queried from the database again, which will further increase the database's QPS (Queries Per Second) and increase the pressure on the database.

[0084] In order to solve the above technical problem, as another possible embodiment of the present invention, as Figure 4 As shown, a business field updating method is also provided. The method in this embodiment is mainly used to update the business field set U corresponding to the business initialization event in the field mapping information table as shown in Table 1. The method is mainly executed by the field mapping configuration module. The business field updating method includes the following steps:

[0085] G100: When the field mapping change information corresponding to the target business is obtained, according to the changed field mapping information table, the request ID corresponding to each sub-business currently included in the target business in the field mapping information table is used as the ID to be updated. The field mapping information table includes the mapping configuration information between the request ID and the business field requested by the request ID, and each sub-business corresponds to a unique request ID.

[0086] Before G100, the service field update method also includes:

[0087] G110: When a configuration change operation is obtained for the field mapping information table, field mapping change information is generated.

[0088] Specifically, the configuration change operation includes: adding, deleting or modifying the mapping information in the field mapping information table.

[0089] In the later use process, the field mapping relationship will inevitably be adjusted according to the actual business changes. Specifically, the configuration platform in the field mapping configuration module can be used to add, delete or modify the mapping information in the field mapping information table. According to the above change operations, the current field mapping information table maintained in the field mapping configuration module will be updated accordingly to ensure that the changed sub-business can obtain the latest data when making a request.

[0090] However, since the mapping relationship between initialization events and the full set of business fields is also configured in the field mapping information table, once the above-mentioned change operation is performed, the historical full set of business fields U needs to be updated. Otherwise, the data pulled into the cache by business initialization cannot meet the query requirements of all business requests, and it is necessary to query the corresponding database again to obtain data.

[0091] In step G110, the configuration platform may be monitored, and once a configuration change operation on the field mapping information table is obtained, field mapping change information is generated, thereby triggering step G100 to obtain the ID to be updated from the changed field mapping information table.

[0092] G200: According to the changed field mapping information table, obtain the request field set A1, A2, ..., Ai, ..., Af corresponding to each ID to be updated (m) Where Ai is the requested field set corresponding to the ith ID to be updated, and the requested field set consists of all the fields requested to be obtained corresponding to the ID to be updated. (m) is the total number of request IDs corresponding to the target business in the changed field mapping information table. i = 1, 2, ..., f (m) .

[0093] G300: Generate the complete set Q of fields to be updated for the target service according to the set of request fields corresponding to each ID to be updated. Q satisfies the following condition: Q = A1 ∪ A2 ∪ … ∪ Ai ∪ … ∪ Af (m) ;

[0094] In the present invention, by taking the union, duplicate fields existing in the set of request fields corresponding to each ID to be updated are removed, and then a new complete set of service fields, that is, the complete set Q of fields to be updated, is generated.

[0095] G400: Use all the service fields in Q as service update fields to update and replace the historical fields in the complete set of service fields.

[0096] G400 includes:

[0097] G401: Replace all the service fields corresponding to the request ID of the service initialization event in the changed field mapping information table with the service update fields. The service initialization event is used to update the data corresponding to the complete set of service fields to the cache when the target service is started.

[0098] Through the method in this embodiment, by using the pre-configured mapping relationship between the request ID and the service fields in the changed field mapping information table, the set of request fields corresponding to each request ID is generated, and then duplicate service fields can be quickly removed by taking the union, and then the latest complete set Q of service fields can be obtained. Thus, the service fields included in Q are all the service field data that the sub-service will necessarily request and use during the operation of the corresponding service, and do not include the service fields that the current sub-service does not use. That is, Q is not all the service fields of a certain service stored in the service database, but only the service field data that all the service parties currently accessing this service system need to use. Therefore, when the initialization event pulls data from the service database, only part of the service database will be queried to reduce the number of request accesses to the service database corresponding to the service fields that are not currently needed, so as to reduce the QPS of the corresponding service database.

[0099] In addition, the latest complete set Q of service fields will also be used to update the complete set U of historical fields, so that when the service is started next time, a more comprehensive and accurate complete set of service fields can be pulled from the service database and stored in the cache, so that the current service requests can basically obtain data from the cache, thereby reducing the number of data queries when responding to service requests, and finally reducing the QPS pressure on the database.

[0100] In addition, although the various steps of the methods in this disclosure are described in a specific order in the drawings, this does not require or imply that these steps must be performed in that specific order, or that all of the shown steps must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.

[0101] From the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software, or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0102] In an exemplary embodiment of this disclosure, there is also provided an electronic device capable of implementing the above method.

[0103] Those skilled in the art can understand that various aspects of the present invention can be implemented as a system, method, or program product. Therefore, various aspects of the present invention can be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, which can be collectively referred to herein as "circuitry", "module", or "system".

[0104] An electronic device according to this embodiment of the present invention. The electronic device is merely an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.

[0105] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: at least one of the above-mentioned processors, at least one of the above-mentioned memories, and a bus connecting different system components (including the memory and the processor).

[0106] Among them, the memory stores program code, and the program code can be executed by the processor, enabling the processor to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification.

[0107] The memory may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) and / or a cache memory, and may further include a read-only memory (ROM).

[0108] The storage may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules, and program data, and implementation of a network environment may be included in each or some combination of these examples.

[0109] The bus may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus structures.

[0110] The electronic device may also communicate with one or more external devices (such as a keyboard, a pointing device, a Bluetooth device, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device, and / or communicate with any device that enables the electronic device to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication may be through an input / output (I / O) interface. And, the electronic device may also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter. The network adapter communicates with other modules of the electronic device through the bus. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0111] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software, or by a manner of software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, and the software product can be stored in a non-volatile storage medium (which may be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.

[0112] In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above method of this specification. In some possible embodiments, various aspects of the present invention may also be implemented in the form of a program product, which includes program code, and when the program product runs on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "exemplary method" section of this specification.

[0113] The program product may employ any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0114] The computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries the readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The readable signal medium may also be any readable medium other than the readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.

[0115] The program code contained on the readable medium may be transmitted by any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0116] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., by using an Internet service provider to connect through the Internet).

[0117] In addition, the above-mentioned drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present invention, rather than for limiting purposes. It is easy to understand that the processes shown in the above-mentioned drawings do not indicate or limit the chronological order of these processes. Additionally, it is also easy to understand that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0118] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, such division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0119] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A dual-channel data consistency maintenance method, characterized in that: The method comprises the following steps: According to the change content included in the cache field change information, the field value corresponding to the changed field in the current cache is updated for the first time; the cache field change information is generated by a business change event, and the business change event is a change event generated after the business initialization event occurs; the change content includes the changed field and the changed field value; When the secondary update time T2 is reached, the field value corresponding to each changed field is obtained from the corresponding database according to the changed fields included in the cache field change information, and the field value corresponding to the changed field in the current cache is updated for the second time; T2 meets the following conditions: T2=T1+t1, where T1 is the completion time of the first update, and t1 is the first preset update interval duration.

2. A dual-channel data consistency maintenance method according to claim 1, characterized in that: t1∈[5s,60s].

3. A dual-channel data consistency maintenance method according to claim 1, characterized in that: The secondary update includes: If the field value corresponding to the changed field obtained from the database is the same as the field value corresponding to the changed field in the current cache, the current cache will not be updated; If the field value corresponding to the changed field obtained from the database is different from the field value corresponding to the changed field in the current cache, the field value corresponding to the changed field obtained from the database is used to replace the field value corresponding to the changed field in the current cache.

4. A dual-channel data consistency maintenance method according to claim 1, characterized in that: Before first updating the field value corresponding to the changed field in the current cache according to the change content included in the cache field change information, the method further includes: Determine the business event type corresponding to the business dynamic information according to the acquired business dynamic information; If the business event type is a business field change event, then cache field change information and database field change information corresponding to the business dynamic information are generated simultaneously; The cache field change information is used to update data in the current cache; the database field change information is used to update data in the corresponding database.

5. A dual-channel data consistency maintenance method according to claim 4, characterized in that: After determining the type of business event corresponding to the business dynamic information, the method further includes: If the service event type is a service initialization event, the request ID corresponding to the service initialization event is obtained according to the field mapping information table; the occurrence time of the service initialization event in the same service is earlier than the occurrence time of the service field change event.

6. A dual-channel data consistency maintenance method according to claim 5, characterized in that: After obtaining the request ID corresponding to the service initialization event, the method further includes: Determine the operation type corresponding to the request ID according to the generation source type corresponding to the request ID; the operation type includes business request and data update; If the operation type is data update, a second request field set corresponding to the request ID is obtained according to the field mapping information table; the field mapping information table includes mapping configuration information between the request ID and the business field requested by the request ID; the second request field set is a full set of corresponding business fields; According to each request field included in the second request field set corresponding to the request ID, obtaining a field value corresponding to each request field from the corresponding database; Update and store the field value corresponding to each requested field obtained into the current cache.

7. A dual-channel data consistency maintenance method according to claim 6, characterized in that: After determining the operation type corresponding to the request ID, the method further includes: If the operation type is a business request, a first request field set corresponding to the request ID is obtained according to the field mapping information table; the field mapping information table includes mapping configuration information between the request ID and the business field requested to be obtained by the request ID; the first request field set is a true subset of the corresponding business field set; According to each request field included in the first request field set corresponding to the request ID, obtaining a field value corresponding to each request field from the current cache; If there is any requested field whose field value in the current cache is an empty set, then the corresponding field value is obtained from the database to which the requested field belongs; The field values ​​obtained from the current cache and the corresponding database are spliced ​​to the corresponding field positions to form response data, and published to the terminal corresponding to the request ID.

8. A dual-channel data consistency maintenance method according to claim 7, characterized in that: Before obtaining the generation source type corresponding to the request ID, the method further includes: A corresponding unique request ID is configured for each type of service request and service initialization event; the service request is generated by the service terminal; If the request ID is an ID corresponding to a business request, then select some fields from the corresponding business field set according to the fields required by the business request; According to the selected part of the fields, mapping configuration information between the request ID and the corresponding fields in the field mapping information table is generated.

9. A non-transitory computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, a dual-channel data consistency maintaining method as described in any one of claims 1 to 8 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for maintaining dual-channel data consistency as described in any one of claims 1 to 8 is implemented.