Data sharing method, device and electronic device between microservice systems
By using cache configuration tables to update data between microservice systems, data sharing pressure and delay problems in distributed systems are solved, the accuracy and efficiency of data acquisition are improved, and the system load is reduced.
Patent Information
- Application Number
- CN202211242321.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-10-11
AI Technical Summary
In distributed core systems, data sharing between microservice systems has pressure and delay problems, especially for data with high access frequency and less logical processing. When data is obtained through microservice systems, it will be given to the microservice system that provides data when obtaining data through microservice systems. It creates greater pressure and takes longer to obtain.
By obtaining the cache configuration table, the cache configuration information and target data of the target microservice system are updated, and the specified memory cache data is cached for direct call by multiple microservice systems to ensure the data consistency between the memory and the database table, thereby improving data acquisition accuracy and efficiency.
Through the update processing of cache configuration tables, direct database queries between microservice systems are reduced, database access pressure is reduced, data acquisition accuracy and efficiency are improved, and the load of microservice systems that provide data is reduced.
Smart Images

Figure CN115934765B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed core systems, and in particular to a method, device and electronic device for sharing data between microservice systems. Background Art
[0002] At present, after the centralized system has developed into a distributed system, everything from applications to databases has been split into multiple independent microservice systems. Due to the division of system boundaries, data that could originally be queried directly through the database (for example, institutional information, currency information, etc.) cannot be directly found and needs to be obtained through the microservice system. For data with a relatively high access frequency and basically no logical processing, obtaining it through the microservice system puts a lot of pressure on the microservice system that provides the data, and it takes a long time to obtain it through the microservice system. Summary of the invention
[0003] The present application provides a data sharing method, device and electronic device between microservice systems to at least solve one of the technical problems in the related art to a certain extent. The technical solution of the present application is as follows:
[0004] According to a first aspect of an embodiment of the present application, a method for sharing data between microservice systems is provided, which is applied to a first microservice system, and includes: obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, obtaining the target data to be updated from a database table of the first microservice system; according to the target data to be updated, updating the data in a designated memory, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table, so that at least one of the microservice systems can directly call it.
[0005] Optionally, the method further includes: when the first microservice system is started for the first time, querying the cache configuration table according to the first identifier of the first microservice system to obtain target cache configuration information for the first microservice system; obtaining target data corresponding to the target cache configuration information in a database table of the first microservice system; and caching the target data corresponding to the target cache information in the designated memory.
[0006] Optionally, obtaining the target data corresponding to the target cache configuration information in the database table of the first microservice system includes: for each target cache configuration information, determining, according to a second identifier of the database table in the target cache configuration information, a target database table corresponding to the second identifier in the first microservice system; and querying the target database table according to a data query condition in the target cache configuration information to obtain the target data corresponding to the target cache configuration information.
[0007] Optionally, when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, obtaining the target data to be updated from the database table of the first microservice system includes: when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, obtaining the first cache configuration information that has an update in the target cache configuration information; and determining the target data corresponding to the first cache configuration information in the first microservice system as the target data to be updated.
[0008] Optionally, the updating process of the data in the designated memory according to the target data to be updated includes: determining the update type of the first cache configuration information; when the update type is a modification type, obtaining the cache configuration information before the change corresponding to the first cache configuration information in the designated memory; and updating the target data corresponding to the cache configuration information before the change in the designated memory according to the target data to be updated.
[0009] Optionally, the method further includes: when the update type is a new type, adding the target data to be updated to the designated memory; when the update type is a deletion type, deleting the target data to be updated in the designated memory.
[0010] Optionally, before updating the target data corresponding to the cache configuration information before the change in the designated memory according to the target data to be updated, the method further includes: invalidating the target data corresponding to the cache configuration information before the change in the designated memory and setting an expiration time.
[0011] Optionally, when the target data corresponding to the target cache configuration information in the first microservice system is updated, obtaining the target data to be updated from a database table of the first microservice system includes: obtaining second cache configuration information in which the corresponding target data in the first microservice system is updated; and determining the target data corresponding to the second cache configuration information in the first microservice system as the target data to be updated.
[0012] Optionally, updating the data in the designated memory according to the target data to be updated includes: determining the update type of the data to be updated; when the update type is a modification type, obtaining the target data corresponding to the second cache information in the designated memory as the data before the change; and updating the data before the change in the designated memory according to the data to be updated.
[0013] Optionally, the method further includes: when the update type is a new type, adding the data to be updated to the designated memory; when the update type is a deletion type, deleting the data to be updated in the designated memory.
[0014] Optionally, before updating the pre-change data in the designated memory according to the data to be updated, the method further includes: invalidating the pre-change data in the designated memory and setting an invalidation time.
[0015] Optionally, the method further includes: sending a query request to the designated memory, wherein the query request includes a data query condition and a microservice system to be queried; when the data to be queried corresponding to the data query condition in the designated memory is not obtained, determining whether the microservice system to be queried is the first microservice system; when the microservice system to be queried is the first microservice system, querying a database table of the first microservice system according to the data query condition to obtain the data to be queried; when the microservice system to be queried is not the first microservice system, calling the service system to be queried to obtain the data to be queried corresponding to the data query condition in the service system to be queried.
[0016] According to a second aspect of an embodiment of the present application, a data sharing device between microservice systems is provided, which is applied to a first microservice system, and includes: a first acquisition module, used to obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; a second acquisition module, used to obtain target data to be updated from a database table of the first microservice system when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system; a first update module, used to update data in a designated memory according to the target data to be updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one of the microservice systems can directly call it.
[0017] Optionally, the device further includes: a third acquisition module, a fourth acquisition module and a cache module; the third acquisition module is used to query the cache configuration table according to the first identifier of the first microservice system when the first microservice system is initially started, and obtain target cache configuration information for the first microservice system; the fourth acquisition module is used to obtain target data corresponding to the target cache configuration information in a database table of the first microservice system; the cache module is used to cache the target data corresponding to the target cache information in the designated memory.
[0018] Optionally, the fourth acquisition module is specifically used to, for each target cache configuration information, determine, according to the second identifier of the database table in the target cache configuration information, a target database table corresponding to the second identifier in the first microservice system; query the target database table according to the data query condition in the target cache configuration information, and obtain the target data corresponding to the target cache configuration information.
[0019] Optionally, the second acquisition module is specifically used to, when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, obtain the first cache configuration information that has an update in the target cache configuration information; and determine the target data corresponding to the first cache configuration information in the first microservice system as the target data to be updated.
[0020] Optionally, the first update module is specifically used to determine the update type of the first cache configuration information; when the update type is a modification type, obtain the pre-change cache configuration information corresponding to the first cache configuration information in the designated memory; and update the target data corresponding to the pre-change cache configuration information in the designated memory according to the target data to be updated.
[0021] Optionally, the device also includes: a first adding module and a first deleting module; the first adding module is used to add the target data to be updated to the designated memory when the update type is a new type; the first deleting module is used to delete the target data to be updated in the designated memory when the update type is a deletion type.
[0022] Optionally, the device further includes: a first invalidation module, configured to invalidate target data corresponding to the cache configuration information before the change in the designated memory, and set an invalidation time.
[0023] Optionally, the second acquisition module is further used to obtain second cache configuration information corresponding to target data in the first microservice system that has been updated; and determine the target data corresponding to the second cache configuration information in the first microservice system as the target data to be updated.
[0024] The device also includes: a first determination module, a fifth acquisition module and a second update module; the first determination module is used to determine the update type of the data to be updated; the fifth acquisition module is used to obtain the target data corresponding to the second cache information in the designated memory as the pre-change data when the update type is a modification type; the second update module is used to update the pre-change data in the designated memory according to the data to be updated.
[0025] Optionally, the device also includes: a second adding module and a second deleting module; the second adding module is used to add the data to be updated to the designated memory when the update type is a new type; the second deleting module is used to delete the data to be updated in the designated memory when the update type is a deletion type.
[0026] Optionally, the device further includes: a second invalidation module, configured to invalidate the pre-change data in the designated memory and set an invalidation time.
[0027] Optionally, the device also includes: a sending module, a second determination module, a first processing module and a second processing module; the sending module is used to send a query request to the designated memory, wherein the query request includes a data query condition and a microservice system to be queried; the second determination module is used to determine whether the microservice system to be queried is the first microservice system when the data to be queried corresponding to the data query condition is not obtained in the designated memory; the first processing module is used to query the database table of the first microservice system according to the data query condition to obtain the data to be queried when the microservice system to be queried is the first microservice system; the second processing module is used to call the service system to be queried to obtain the data to be queried corresponding to the data query condition in the service system to be queried when the microservice system to be queried is not the first microservice system.
[0028] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a data sharing method between microservice systems as described in the embodiment of the first aspect of the present application.
[0029] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data sharing method between microservice systems as described in the embodiment of the first aspect of the present application.
[0030] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, including: a computer program, which, when executed by a processor, implements the data sharing method between microservice systems as described in the embodiment of the first aspect of the present application.
[0031] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:
[0032] By obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system; according to the target data to be updated, the data in the designated memory is updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it, thereby, when there is an update to the target cache configuration information of the first microservice system or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained from the designated memory by the microservice system.
[0033] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.
[0035] Figure 1 It is a flowchart of a data sharing method between microservice systems shown in the first embodiment of the present application;
[0036] Figure 2 It is a flowchart of a data sharing method between microservice systems shown in the second embodiment of the present application;
[0037] Figure 3is a flow chart of a data sharing method between microservice systems shown in the third embodiment of the present application;
[0038] Figure 4 This is a flow chart showing a method for sharing data between microservice systems according to the fourth embodiment of the present application;
[0039] Figure 5 This is a flowchart of a method for sharing data between microservice systems as shown in the fifth embodiment of the present application;
[0040] Figure 6 is a schematic diagram of the structure of a data sharing device between microservice systems shown in the sixth embodiment of the present application;
[0041] Figure 7 It is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0042] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0043] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application 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 interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0044] The following describes a method, device, and electronic device for sharing data between microservice systems in an embodiment of the present application with reference to the accompanying drawings.
[0045] Figure 1 It is a flowchart of the data sharing method between microservice systems shown in the first embodiment of the present application.
[0046] It should be noted that, in the embodiment of the present application, the executor of the data sharing method between microservice systems may be a data sharing device between microservice systems, and the data sharing device between microservice systems may be configured in an electronic device so that the electronic device can perform the data sharing function between microservice systems.
[0047] Among them, the electronic devices may include but are not limited to microservice systems and servers, and microservice systems can communicate with each other and between microservice systems and servers.
[0048] It should be noted that there may be multiple microservice systems providing shared data (target data), and the data sharing processing method between microservice systems can apply the first microservice system. The first microservice system is one of the multiple microservice systems providing shared data (target data). The microservice system using shared data can communicate with the microservice system providing shared data, that is, it can communicate with the first microservice system.
[0049] like Figure 1 As shown, the data sharing method between the microservice systems may include the following steps:
[0050] Step 101, obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system.
[0051] It should be noted that before obtaining the cache configuration table, the cache configuration table and cache configuration information are configured according to the demand for shared data by the microservice system that uses the shared data. The cache configuration table is used to store cache configuration information of multiple microservice systems, and the configured cache configuration table is stored in multiple microservice systems.
[0052] The cache configuration information may include: the identifier (ID) of the cache configuration table, the identifier of the database table, the result field of the database table, the query condition, whether it is unique, whether to enable cache, the system identifier of the microservice system, and other information.
[0053] Among them, the identifier (ID) of the cache configuration table, such as the number and name of the cache configuration table; the identifier of the database table refers to the identifier of the source database table of the data corresponding to the cache configuration information, such as the number and table name of the database table; the system identifier of the microservice system, such as the system number, system name, etc., is not specifically limited in the embodiments of the present application.
[0054] Among them, the microservice system can be, for example, a public operation system, a deposit system, a loan system, an accounting system, etc., which can be set according to actual needs, and the embodiments of the present application do not make specific limitations on this.
[0055] In an embodiment of the present application, the process of obtaining the cache configuration table may be to query according to the system identifier configured in the system configuration file of the microservice system to obtain the cache configuration table corresponding to the system identifier.
[0056] For the first microservice system, a query may be performed according to a system identifier configured in a system configuration file of the first microservice system to obtain a cache configuration table corresponding to the system identifier.
[0057] Step 102, when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system.
[0058] Among them, the first microservice system can be, for example, a public operation system, a deposit system, a loan system, an accounting system, etc., and the embodiment of the present application does not make any specific limitations on this.
[0059] Among them, the target cache configuration information of the first microservice system is the same as the cache configuration information. Please refer to the relevant description of the cache configuration information, which will not be described in detail here.
[0060] In one implementation, a scenario in which the target cache configuration information for the first microservice system is updated in the cache configuration table may be that the target cache configuration information is modified, deleted, or added.
[0061] Among them, taking the modification of the target cache configuration information as an example, there is a change in a certain cache configuration information in the target cache configuration information, such as a change in the query condition, which can be a manual change in the query condition, such as a staff member modifies the description of the field on the terminal, or other machines modify the information of the field, etc. Based on the above trigger form, the electronic device where the cache configuration table is located responds to the human operation, or the modification instruction, etc. to perform the above steps: obtain the target data to be updated from the database table of the first microservice system; take the deletion of the target cache configuration information as an example, a certain cache configuration information is deleted in the target cache configuration information; take the addition of the target cache configuration information as an example, a cache configuration information is added to the target cache configuration information. Triggering the acquisition of the target data to be updated by deletion will not be repeated.
[0062] In another embodiment, the target data corresponding to the target cache configuration information in the first microservice system is updated, that is, the corresponding target data in the database table is updated. The corresponding scenario can be that the database table is a currency table, for example, the currency table includes US dollars and RMB, and due to business needs, British pounds need to be added, then the corresponding target data in the database table needs to be updated. Triggering the acquisition of the target data to be updated by updating the target data will not be repeated.
[0063] In an embodiment of the present application, in a scenario where an update is present, the database table is queried based on the updated cache configuration information, and the target data to be updated is obtained from the database table.
[0064] In an embodiment of the present application, a microservice system that provides shared data (for example, a first microservice system) provides a shared data operation method SDK (Software Development Kit), which includes various methods for operating cached data, such as a shared data query method and a shared data maintenance method.
[0065] Among them, the shared data maintenance method is used for the microservice system that provides shared data. The shared data maintenance method, for example, is a method for obtaining the target data to be updated from the database table of the first microservice system. The specific execution process can be implemented in any of the embodiments of the present application, and the embodiments of the present application are not limited to this.
[0066] Among them, the shared data query method is used by the microservice system that uses shared data. The microservice system that uses shared data can integrate the SDK, call the shared data query method in the SDK, and obtain the shared data (shared target data).
[0067] Optionally, when the microservice system using shared data fails to obtain the shared data or the designated storage is unavailable, it is determined whether the microservice system using the shared data is the microservice system providing the shared data based on the system identifier in the system configuration file of the microservice system using the shared data and the system identifier in the data query condition; if the microservice system using the shared data is the microservice system providing the shared data, its own database table is directly queried to obtain the shared data; if the microservice system using the shared data is not the microservice system providing the shared data, the microservice system providing the shared data is called to obtain the shared data.
[0068] Step 103: update the data in the designated memory according to the target data to be updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it.
[0069] In an embodiment of the present application, the update scenario corresponding to the target data to be updated, that is, the cache configuration information is updated or the target data is updated, the update type of the cache configuration information update or the target data update is determined, and the data in the specified memory is updated according to the update type.
[0070] In summary, by obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system; according to the target data to be updated, the data in the designated memory is updated, wherein the data corresponding to each cache configuration information in the cache configuration table is stored in the designated memory so that at least one microservice system can directly call it, thereby, when there is an update to the target cache configuration information of the first microservice system or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained from the designated memory by the microservice system.
[0071] Figure 2 It is a flow chart of the data sharing method between microservice systems shown in the second embodiment of the present application. It should be noted that the data sharing method between microservice systems in the embodiment of the present application can be applied to the first microservice system.
[0072] like Figure 2 As shown, the data sharing method between the microservice systems may include the following steps:
[0073] Step 201, obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system.
[0074] Step 202: When there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system.
[0075] Step 203: update the data in the designated memory according to the target data to be updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it.
[0076] It should be noted that the execution process of step 201, step 202 and step 203 can be implemented in any way in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be repeated.
[0077] Step 204, when the first microservice system is started for the first time, query the cache configuration table according to the first identifier of the first microservice system to obtain target cache configuration information for the first microservice system.
[0078] Among them, the first identifier can be the system name or system number of the first microservice system, which is not specifically limited in this embodiment of the present application.
[0079] In an embodiment of the present application, the first identifier of the first microservice system is configured in a system configuration file of the first microservice system. A query is performed according to the first identifier configured in the system configuration file to obtain a cache configuration table corresponding to the first identifier, and obtain target cache configuration information for the first microservice system in the cache configuration table.
[0080] Step 205: Obtain target data corresponding to the target cache configuration information in the database table of the first microservice system.
[0081] As an implementation mode, the process of the first microservice system executing step 205 may, for example, be: for each target cache configuration information, according to the second identifier of the database table in the target cache configuration information, determine the target database table corresponding to the second identifier in the first microservice system; according to the data query condition in the target cache configuration information, query the target database table to obtain the target data corresponding to the target cache configuration information.
[0082] Among them, the data query conditions may include query keywords such as the table name of the database table in the target cache configuration information, the database table result field, and the query conditions; the second identifier may be the number or table name of the database table, which is not limited in the embodiment of the present application.
[0083] Optionally, the process of querying the target database table according to the data query conditions to obtain the target data corresponding to the target cache configuration information can be, for example, concatenating the table name, database table result field, and query conditions of the database table in the target cache configuration information according to SQL syntax to obtain an SQL statement, and querying the target database table according to the SQL statement to obtain the target data corresponding to the target cache configuration information.
[0084] Step 206: Cache the target data corresponding to the target cache information into a designated memory.
[0085] In summary, by obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system; according to the target data to be updated, the data in the designated memory is updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it; when the first microservice system is initially started, the cache configuration table is queried according to the first identifier of the first microservice system to obtain the target cache configuration information for the first microservice system; the target data corresponding to the target cache configuration information in the database table of the first microservice system is obtained; the target data corresponding to the target cache information is cached in the designated memory, thereby, when there is an update to the target cache configuration information of the first microservice system or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained by the microservice system from the designated memory.
[0086] In order to clearly illustrate the above embodiment, when there is an update in the target cache configuration information of the first microservice system in the cache configuration table, how to obtain the target data to be updated from the database table of the first microservice system, that is, the shared data maintenance method, the present application proposes another data sharing method between microservice systems.
[0087] Figure 3 It is a flow chart of the data sharing method between microservice systems shown in the third embodiment of the present application. It should be noted that the data sharing method between microservice systems in the embodiment of the present application can be applied to the first microservice system.
[0088] like Figure 3 As shown, the data sharing method between the microservice systems may include the following steps:
[0089] Step 301, obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system.
[0090] It should be noted that the execution process of step 301 can be implemented in any of the embodiments of the present application. The embodiments of the present application do not limit this and will not be described in detail.
[0091] Step 302: When there is an update in the target cache configuration information for the first microservice system in the cache configuration table, the first cache configuration information with an update in the target cache configuration information is obtained.
[0092] The target cache configuration information being updated may be a cache configuration information being added to the cache configuration table, or a cache configuration information being deleted, or a cache configuration information being modified, such as a query condition being changed.
[0093] In an embodiment of the present application, in one implementation, if the target cache configuration information is updated to add a new cache configuration information, the first cache configuration information is the newly added cache configuration information; in another implementation, if the target cache configuration information is updated to delete a cache configuration information, the first cache configuration information is the deleted cache configuration information; in another implementation, if the target cache configuration information is updated to modify a certain cache configuration information, the first cache configuration information is the modified cache configuration information.
[0094] Step 303: determine the target data corresponding to the first cache configuration information in the first microservice system as the target data to be updated.
[0095] In an embodiment of the present application, the first microservice system queries the database table according to the first cache configuration information, obtains the target data corresponding to the first cache configuration information, and determines the target data as the target data to be updated.
[0096] Step 304: update the data in the designated memory according to the target data to be updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it.
[0097] As an implementation method, the first microservice system determines the update type of the first cache configuration information; when the update type is a modification type, obtains the cache configuration information before the change corresponding to the first cache configuration information in the specified memory; and updates the target data corresponding to the cache configuration information before the change in the specified memory according to the target data to be updated.
[0098] Optionally, when the update type is a new type, the target data to be updated is added to the specified memory; when the update type is a deletion type, the target data to be updated in the specified memory is deleted.
[0099] Therefore, when the first cache configuration information is modified cache configuration information, the first microservice system specifies the cache configuration information before the change corresponding to the first cache configuration information in the memory, and updates the target data corresponding to the cache configuration information before the change in the specified memory; when the first cache configuration information is newly added cache configuration information, the first microservice system adds the target data corresponding to the first cache configuration information to the specified memory; when the first cache configuration information is deleted cache configuration information, the first microservice system deletes the target data corresponding to the first cache configuration information in the specified memory to ensure that the target data of the database table of the first microservice system is consistent with the data of the specified memory, so that the data read from the specified memory is accurate and reliable.
[0100] In some embodiments, before step 304, that is, before updating the target data in the designated memory according to the data to be updated, the first microservice system invalidates the target data corresponding to the cache configuration information before the change in the designated memory and sets an expiration time.
[0101] Among them, the expiration time can be set according to actual needs, and the embodiments of the present application do not limit this.
[0102] This is because, during the process of updating the target data, if there is a query request for data in a specified memory, and the target data corresponding to the cache configuration information before the change in the specified memory has not been invalidated, the queried target data is the target data corresponding to the cache configuration information before the change, resulting in an incorrect query result.
[0103] Therefore, before updating the target data corresponding to the cache configuration information before the change in the specified memory, the target data corresponding to the cache configuration information before the change in the specified memory is invalidated to ensure the correctness of the query result. In addition, the target data corresponding to the cache configuration information before the change in the specified memory is not deleted to avoid all query requests being switched to the database, thereby reducing the access pressure on the database table.
[0104] In summary, by obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, the first cache configuration information with an update in the target cache configuration information is obtained; the target data corresponding to the first cache configuration information in the first microservice system is determined as the target data to be updated; according to the target data to be updated, the data in the designated memory is updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it, thereby, when there is an update to the target cache configuration information of the first microservice system or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained from the designated memory by the microservice system.
[0105] In order to clearly illustrate the above embodiment, when the target data corresponding to the target cache configuration information in the first microservice system is updated, how to obtain the target data to be updated from the database table of the first microservice system, that is, the shared data maintenance method, the present application proposes another data sharing method between microservice systems.
[0106] Figure 4 It is a flow chart of the data sharing method between microservice systems shown in the fourth embodiment of the present application. It should be noted that the data sharing method between microservice systems in the embodiment of the present application can be applied to the first microservice system.
[0107] like Figure 4 As shown, the data sharing method between the microservice systems may include the following steps:
[0108] Step 401, obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system.
[0109] It should be noted that the execution process of step 401 can be implemented in any of the embodiments of the present application. The embodiments of the present application do not limit this and will not be described in detail.
[0110] Step 402: Obtain second cache configuration information corresponding to target data in the first microservice system that has been updated.
[0111] In an embodiment of the present application, when the corresponding target data in the database table of the first microservice system is updated, second cache configuration information corresponding to the updated target data is obtained.
[0112] Step 403: determine the target data corresponding to the second cache configuration information in the first microservice system as the target data to be updated.
[0113] Step 404: update the data in the designated memory according to the target data to be updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it.
[0114] As an implementation method, the first microservice system determines the update type of the data to be updated; when the update type is a modification type, obtains the target data corresponding to the second cache information in the specified memory as the pre-change data; and updates the pre-change data in the specified memory according to the data to be updated.
[0115] Optionally, when the update type is a new addition type, the data to be updated is added to a designated memory; when the update type is a deletion type, the data to be updated in the designated memory is deleted.
[0116] Therefore, when the target data to be updated is newly added data, the first microservice system can directly update the target data to be updated to the designated memory; when the target data to be updated is deleted data, the first microservice system can directly delete the target data to be updated in the designated memory to ensure that the target data in the database table of the first microservice system is consistent with the data in the designated memory, so that the data read from the designated memory is accurate and reliable.
[0117] In an embodiment of the present application, before updating the pre-change data in the designated storage according to the data to be updated, the first microservice system invalidates the pre-change data in the designated storage and sets an invalidation time.
[0118] Among them, the expiration time can be set according to actual needs, and this application does not limit this.
[0119] Because, in the process of updating the data before the change, if there is a query request for querying the data in the specified storage, and the data before the change in the specified storage is not invalidated, the data queried is the data before the change, resulting in an incorrect query result.
[0120] Therefore, before the pre-change data is updated, the pre-change data in the specified storage is invalidated to ensure the correctness of the query result. In addition, the pre-change data in the specified storage is not deleted to avoid all query requests being switched to the database table, thereby reducing the access pressure on the database table.
[0121] In summary, by obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; obtaining second cache configuration information whose corresponding target data in the first microservice system is updated; determining the target data corresponding to the second cache configuration information in the first microservice system as the target data to be updated; and updating the data in the designated memory according to the target data to be updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it, thereby, when the target cache configuration information of the first microservice system is updated or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained from the designated memory by the microservice system.
[0122] Figure 5 It is a flow chart of the data sharing method between microservice systems shown in the fifth embodiment of the present application. It should be noted that the data sharing method between microservice systems in the embodiment of the present application can be applied to the first microservice system.
[0123] like Figure 5 As shown, the data sharing method between the microservice systems may include the following steps:
[0124] Step 501, obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system.
[0125] Step 502: When there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system.
[0126] Step 503: update the data in the designated memory according to the target data to be updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it.
[0127] It should be noted that the execution process of steps 501 to 503 can be implemented in any way in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be repeated.
[0128] Step 504: Send a query request to the designated storage, wherein the query request includes a data query condition and a microservice system to be queried.
[0129] Among them, the data query conditions may include query keywords such as the table name of the database table in the target cache configuration information, the database table result field, and the query conditions; the second identifier may be the number or table name of the database table, which is not limited in the embodiment of the present application.
[0130] Optionally, a query request is sent to a designated storage device so that the designated storage device determines query keywords such as the table name of the database table, the result field of the database table, and the query condition according to the data query condition in the query request, concatenates the table name of the database table, the result field of the database table, and the query condition according to the SQL syntax to obtain an SQL statement, queries the designated storage device according to the SQL statement to obtain the query result, and determines whether the data to be queried corresponding to the data query condition in the designated storage device is obtained according to the query result.
[0131] Step 505: When the to-be-queried data corresponding to the data query condition is not obtained in the designated memory, it is determined whether the to-be-queried microservice system is the first microservice system.
[0132] In one implementation, failure to obtain the data to be queried may be due to the absence of the data to be queried in the specified memory; in another implementation, failure to obtain the data to be queried may be due to the unavailability of the specified memory, and an error indication is returned.
[0133] In some embodiments, the data query condition may include a system identifier, and the first microservice system may compare the system identifier in the system configuration file with the system identifier in the data query condition. If the system identifiers are consistent, it means that the microservice system to be queried is the first microservice system; if the system identifiers are inconsistent, it means that the microservice system to be queried is not the first microservice system.
[0134] Step 506: When the microservice system to be queried is the first microservice system, query the database table of the first microservice system according to the data query condition to obtain the data to be queried.
[0135] In the embodiment of the present application, when the microservice system to be queried is the first microservice system, it indicates that the first microservice system is the provider of the data to be queried, that is, the user of the data to be queried is the provider itself.
[0136] Optionally, the data to be queried is located in a database table of the first microservice system, and the first microservice system may directly query its own database table to obtain the data to be queried.
[0137] Step 507: When the microservice system to be queried is not the first microservice system, the service system to be queried is called to obtain the data to be queried corresponding to the data query condition in the service system to be queried.
[0138] In an embodiment of the present application, when the microservice system to be queried is not the first microservice system, the user of the data to be queried is not the data provider itself. For example, the microservice system to be queried may be the second microservice system, which provides the data to be queried. The first microservice system cannot directly query the database table of the second microservice system, but may call the second microservice system to obtain the data to be queried.
[0139] In summary, by obtaining a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system; according to the target data to be updated, the data in the designated memory is updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it; a query request is sent to the designated memory, wherein the query request includes a data query condition and a microservice system to be queried; if the data corresponding to the data query condition in the designated memory is not obtained, When the corresponding data to be queried is to be queried, determine whether the microservice system to be queried is the first microservice system; when the microservice system to be queried is the first microservice system, query the database table of the first microservice system according to the data query conditions to obtain the data to be queried; when the microservice system to be queried is not the first microservice system, call the service system to be queried to obtain the data to be queried corresponding to the data query conditions in the service system to be queried, thereby, when the target cache configuration information of the first microservice system is updated or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained by the microservice system from the designated memory. In addition, when the microservice system to be queried is not the first microservice system, call the second microservice system to obtain the data to be queried, thereby ensuring the high availability of the service.
[0140] In order to explain the above embodiment more clearly, an example is now given for illustration.
[0141] For example, first, according to the demand for cache data (target data), a cache configuration table and cache configuration information can be configured. The cache configuration table is used to store cache configuration information of multiple microservice systems. The configured cache configuration table is stored in multiple microservice systems. The cache configuration information may include: the identifier of the source database table of the data corresponding to the cache configuration information, the database table result field, the query condition, whether it is unique, the system identifier of the microservice system, and other information. When the first microservice system is started for the first time, a query is performed according to the system identifier (first identifier) in the system configuration file of the first microservice system to obtain the cache configuration table corresponding to the system identifier, and the target cache configuration information for the first microservice system is obtained. According to the identifier (second identifier) of the database table in the target cache configuration information, the corresponding target database table is determined, and the table name, database table result field, and query condition of the database table in the target cache configuration information are spliced to obtain an SQL statement, and the target database table is queried according to the SQL statement to obtain the target data (SQL statement execution result) corresponding to the target cache configuration information, and the target data is cached in the designated memory (cache service).
[0142] When there is an update to the target cache configuration information of the first microservice system in the cache configuration table, the first cache configuration information with an update in the target cache configuration information is obtained; the target data corresponding to the first cache configuration information in the first microservice system is determined as the target data to be updated, and the update type of the first cache configuration information is determined. When the update type is a new type, the cache configuration information before the change corresponding to the first cache configuration information in the specified memory is obtained, and the target data corresponding to the cache configuration information before the change is updated according to the data to be updated; when the update type is a deletion type, the data to be updated in the specified memory is deleted; when the update type is a modification type, the target data to be updated is added to the specified memory.
[0143] Before updating the target data corresponding to the cache configuration information before the change in the specified storage, the target data corresponding to the cache configuration information before the change is invalidated and an invalidation time is set to avoid transferring all query requests for the specified storage to the database table, thereby reducing the access pressure on the database table.
[0144] When the target data corresponding to the target cache configuration information in the first microservice system is updated, the second cache configuration information in which the corresponding target data in the first microservice system is updated is obtained; the target data corresponding to the second cache configuration information in the first microservice system is determined as the target data to be updated, and the update type of the data to be updated is determined. When the update type is a modification type, the target data corresponding to the second cache information in the designated memory is obtained as the pre-change data, and the pre-change data in the designated memory is updated according to the data to be updated; when the update type is a new addition type, the data to be updated is added to the designated memory; when the update type is a deletion type, the data to be updated in the designated memory is deleted.
[0145] Before updating the pre-change data in the designated storage, invalidate the pre-change data in the designated storage and set an invalidation time to avoid transferring all query requests for the designated storage to the database table, thereby reducing the access pressure on the database table.
[0146] The first microservice system sends a query request to the designated storage so that the designated storage can query the target data according to the received query request, and directly return the query result when the query result is obtained; when no query result is obtained or the cache service is unavailable, it is determined whether the microservice system to be queried is the first microservice system. If the microservice system to be queried is the first microservice system, the first microservice system can directly operate the database table to obtain the data to be queried; if the microservice system to be queried is not the first microservice system, the first microservice system automatically calls a remote microservice system, such as the second microservice system, to obtain the data to be queried, thereby ensuring high availability of the service.
[0147] The data sharing method between microservice systems of the embodiment of the present application is to obtain the target data to be updated from the database table to update the data in the designated memory when the target cache configuration information of the first microservice system is updated or the target data corresponding to the target cache configuration information is updated, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained from the designated memory by the microservice system, and calling the designated memory to obtain data, reducing calls between microservice systems, thereby reducing the access pressure of the microservice system providing shared data. In addition, when the microservice system to be queried is not the first microservice system, the second microservice system is called to obtain the data to be queried, thereby ensuring the high availability of the service.
[0148] With the above Figures 1 to 5 Corresponding to the data sharing method between microservice systems provided in the embodiment, the present application also provides a data sharing device between microservice systems. Figures 1 to 5The data sharing method between microservice systems provided in the embodiment corresponds to the method, so the implementation method of the data sharing method between microservice systems is also applicable to the data sharing device between microservice systems provided in the embodiment of the present application, and will not be described in detail in the embodiment of the present application.
[0149] Figure 6 1 is a schematic diagram of the structure of the data sharing device between microservice systems shown in the sixth embodiment of the present application. The data sharing device between microservice systems in the embodiment of the present application can be applied to the first microservice system.
[0150] Reference Figure 6 The data sharing device 600 between microservice systems may include: a first acquisition module 610, a second acquisition module 620, and a first update module 630.
[0151] Among them, the first acquisition module 610 is used to obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; the second acquisition module 620 is used to obtain the target data to be updated from the database table of the first microservice system when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system; the first update module 630 is used to update the data in the designated memory according to the target data to be updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one of the microservice systems can directly call it.
[0152] As a possible implementation method of an embodiment of the present application, the device also includes: a third acquisition module, a fourth acquisition module and a cache module; the third acquisition module is used to query the cache configuration table according to the first identifier of the first microservice system when the first microservice system is initially started, and obtain target cache configuration information for the first microservice system; the fourth acquisition module is used to obtain target data corresponding to the target cache configuration information in a database table of the first microservice system; the cache module is used to cache the target data corresponding to the target cache information in the designated memory.
[0153] As a possible implementation method of an embodiment of the present application, the fourth acquisition module is specifically used to, for each target cache configuration information, determine, according to the second identifier of the database table in the target cache configuration information, a target database table corresponding to the second identifier in the first microservice system; query the target database table according to the data query condition in the target cache configuration information, and obtain the target data corresponding to the target cache configuration information.
[0154] As a possible implementation manner of an embodiment of the present application, the second acquisition module 620 is specifically used to, when there is an update in the target cache configuration information for the first microservice system in the cache configuration table, obtain the first cache configuration information in the target cache configuration information that has an update; and determine the target data corresponding to the first cache configuration information in the first microservice system as the target data to be updated.
[0155] As a possible implementation method of an embodiment of the present application, the first update module 630 is specifically used to determine the update type of the first cache configuration information; when the update type is a modification type, obtain the pre-change cache configuration information corresponding to the first cache configuration information in the designated memory; and update the target data corresponding to the pre-change cache configuration information in the designated memory according to the target data to be updated.
[0156] As a possible implementation method of an embodiment of the present application, the device also includes: a first adding module and a first deleting module; the first adding module is used to add the target data to be updated to the designated memory when the update type is a new type; the first deleting module is used to delete the target data to be updated in the designated memory when the update type is a deletion type.
[0157] As a possible implementation of the embodiment of the present application, the device also includes: a first invalidation module, which is used to invalidate the target data corresponding to the pre-change cache configuration information in the designated memory and set an invalidation time.
[0158] As a possible implementation method of an embodiment of the present application, the second acquisition module 620 is further used to obtain second cache configuration information in which the corresponding target data in the first microservice system is updated; and determine the target data corresponding to the second cache configuration information in the first microservice system as the target data to be updated.
[0159] In a possible implementation manner of an embodiment of the present application, the device also includes: a first determination module, a fifth acquisition module and a second update module; the first determination module is used to determine the update type of the data to be updated; the fifth acquisition module is used to obtain the target data corresponding to the second cache information in the designated memory as the pre-change data when the update type is a modification type; the second update module is used to update the pre-change data in the designated memory according to the data to be updated.
[0160] As a possible implementation method of the embodiment of the present application, the device also includes: a second adding module and a second deleting module; the second adding module is used to add the data to be updated to the designated memory when the update type is a new type; the second deleting module is used to delete the data to be updated in the designated memory when the update type is a deletion type.
[0161] As a possible implementation of the embodiment of the present application, the device further includes: a second invalidation module, configured to invalidate the pre-change data in the designated memory and set an invalidation time.
[0162] As a possible implementation method of an embodiment of the present application, the device also includes: a sending module, a second determination module, a first processing module and a second processing module; the sending module is used to send a query request to the designated memory, wherein the query request includes a data query condition and a microservice system to be queried; the second determination module is used to determine whether the microservice system to be queried is the first microservice system when the data to be queried corresponding to the data query condition is not obtained in the designated memory; the first processing module is used to query the database table of the first microservice system according to the data query condition to obtain the data to be queried when the microservice system to be queried is the first microservice system; the second processing module is used to call the service system to be queried to obtain the data to be queried corresponding to the data query condition in the service system to be queried when the microservice system to be queried is not the first microservice system.
[0163] The data sharing device between microservice systems of the embodiment of the present application obtains a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system; when there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, the target data to be updated is obtained from the database table of the first microservice system; according to the target data to be updated, the data in the designated memory is updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one microservice system can directly call it, thereby, when there is an update to the target cache configuration information of the first microservice system or the target data corresponding to the target cache configuration information is updated, the target data to be updated is obtained from the database table to update the data in the designated memory, thereby ensuring that the data in the designated memory is consistent with the data in the database table, thereby improving the accuracy of the data obtained from the designated memory by the microservice system.
[0164] In an exemplary embodiment, an electronic device is also provided.
[0165] Among them, electronic equipment includes:
[0166] processor;
[0167] a memory for storing processor-executable instructions;
[0168] The processor is configured to execute instructions to implement the data sharing method between microservice systems proposed in any of the aforementioned embodiments.
[0169] As an example, Figure 7 is a schematic diagram of the structure of an electronic device 700 shown in an exemplary embodiment of the present application. Figure 7 As shown, the electronic device 700 may further include:
[0170] The memory 710 and the processor 720, a bus 730 connecting different components (including the memory 710 and the processor 720), the memory 710 stores a computer program, and when the processor 720 executes the program, the point cloud image enhancement method described in the embodiment of the present application is implemented.
[0171] Bus 730 represents 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 architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0172] The electronic device 700 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 700, including volatile and non-volatile media, removable and non-removable media.
[0173] The memory 710 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 740 and / or cache memory 750. The electronic device 700 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 760 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to bus 730 via one or more data medium interfaces. Memory 710 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0174] A program / utility 780 having a set (at least one) of program modules 770 may be stored, for example, in the memory 710, such program modules 770 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 770 generally perform the functions and / or methods of the embodiments described herein.
[0175] The electronic device 700 may also communicate with one or more external devices 790 (e.g., keyboard, pointing device, display 791, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 792. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 793. As shown, the network adapter 793 communicates with other modules of the electronic device 700 through a bus 730. 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 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0176] The processor 720 executes various functional applications and data processing by running the programs stored in the memory 710 .
[0177] It should be noted that the implementation process and technical principles of the electronic device of this embodiment refer to the aforementioned explanation of the data sharing method between microservice systems in the embodiment of the present application, and will not be repeated here.
[0178] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the above instructions can be executed by a processor of an electronic device to complete the data sharing method between microservice systems proposed in any of the above embodiments. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a tape, a floppy disk, an optical data storage device, etc.
[0179] In an exemplary embodiment, a computer program product is also provided, including a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the data sharing method between microservice systems proposed in any of the above embodiments is implemented.
[0180] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0181] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A data sharing method between microservice systems, characterized in that: Applied to the first microservice system, including: Obtain a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system, the cache configuration table is configured when the first microservice system has a need to share data before obtaining the cache configuration table, and is stored in the first microservice system, the cache configuration information includes an identifier of the cache configuration table, an identifier of a database table, a result field of the database table, a query condition, whether it is unique, whether to enable cache, and a system identifier of the microservice system; When the first microservice system is started for the first time, query the cache configuration table according to the first identifier of the first microservice system to obtain target cache configuration information for the first microservice system; Determine the corresponding target database table according to the identifier of the database table in the target cache configuration information; The table name, database table result field, and query condition of the database table in the target cache configuration information are concatenated to obtain an SQL statement; Query the target database table according to the SQL statement to obtain the target data corresponding to the target cache configuration information; Cache the target data in a designated memory; When there is an update to the target cache configuration information for the first microservice system in the cache configuration table, and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system, obtaining the target data to be updated from the database table of the first microservice system; According to the target data to be updated, the data in the designated memory is updated, wherein the designated memory stores data corresponding to each cache configuration information in the cache configuration table so that at least one of the microservice systems can directly call it.
2. The method according to claim 1, characterized in that The acquiring target data corresponding to the target cache configuration information in the database table of the first microservice system includes: For each target cache configuration information, determine the target database table corresponding to the second identifier in the first microservice system according to the second identifier of the database table in the target cache configuration information; The target database table is queried according to the data query condition in the target cache configuration information to obtain the target data corresponding to the target cache configuration information.
3. The method according to claim 1, characterized in that When the target cache configuration information for the first microservice system in the cache configuration table is updated, obtaining the target data to be updated from the database table of the first microservice system includes: When there is an update in the target cache configuration information for the first microservice system in the cache configuration table, obtaining the first cache configuration information in the target cache configuration information that has an update; The target data corresponding to the first cache configuration information in the first microservice system is determined as the target data to be updated.
4. The method according to claim 3, characterized in that The updating process of the data in the designated memory according to the target data to be updated includes: Determining an update type of the first cache configuration information; When the update type is a modification type, obtaining cache configuration information before change corresponding to the first cache configuration information in the designated memory; According to the target data to be updated, the target data corresponding to the cache configuration information before the change in the designated memory is updated.
5. The method according to claim 1, characterized in that When the target data corresponding to the target cache configuration information in the first microservice system is updated, obtaining the target data to be updated from the database table of the first microservice system includes: Acquire second cache configuration information in which corresponding target data in the first microservice system is updated; The target data corresponding to the second cache configuration information in the first microservice system is determined as the target data to be updated.
6. The method according to claim 5, characterized in that The updating process of the data in the designated memory according to the target data to be updated includes: Determining an update type of the target data to be updated; When the update type is a modification type, obtaining target data corresponding to the second cache configuration information in the designated memory as pre-change data; The pre-change data in the designated memory is updated according to the target data to be updated.
7. The method according to claim 1, characterized in that The method further comprises: Sending a query request to the designated storage, wherein the query request includes a data query condition and a microservice system to be queried; When the to-be-queried data corresponding to the data query condition in the designated memory is not obtained, determining whether the to-be-queried microservice system is the first microservice system; When the microservice system to be queried is the first microservice system, querying a database table of the first microservice system according to the data query condition to obtain the data to be queried; When the microservice system to be queried is not the first microservice system, the microservice system to be queried is called to obtain the data to be queried corresponding to the data query condition in the microservice system to be queried.
8. A data sharing device between microservice systems, characterized in that: Applied to the first microservice system, including: A first acquisition module is used to acquire a cache configuration table; wherein the cache configuration table includes cache configuration information for at least one microservice system, the cache configuration table is configured when the first microservice system has a need to share data before acquiring the cache configuration table, and is stored in the first microservice system, the cache configuration information includes an identifier of the cache configuration table, an identifier of a database table, a result field of the database table, a query condition, whether it is unique, whether to enable cache, and a system identifier of the microservice system; A third acquisition module is used to query the cache configuration table according to the first identifier of the first microservice system when the first microservice system is started for the first time, and obtain target cache configuration information for the first microservice system; The fourth acquisition module is used to determine the corresponding target database table according to the identifier of the database table in the target cache configuration information; concatenate the table name, database table result field, and query condition of the database table in the target cache configuration information to obtain an SQL statement; query the target database table according to the SQL statement to obtain the target data corresponding to the target cache configuration information; A cache module, used for caching the target data into a designated memory; A second acquisition module is used to acquire target data to be updated when there is an update to the target cache configuration information of the first microservice system in the cache configuration table and / or when there is an update to the target data corresponding to the target cache configuration information in the first microservice system; The first update module is used to update the data in the designated memory according to the target data to be updated, wherein the designated memory stores the data corresponding to each cache configuration information in the cache configuration table so that at least one of the microservice systems can directly call it.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the data sharing method between microservice systems as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Component sharing method and device under micro-service architecture and electronic equipment
CN109491653A
A data sharing method between micro-services
CN109922151A
Data sharing method and device, storage medium and electronic equipment
CN111078789A
Micro-service configuration information updating method, device and system, medium and equipment
CN112579118A
Data sharing method and device
CN113934744A
