Git-based cross-library synchronization method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202311600444.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-24
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-11-24
AI Technical Summary
[0003]但是现有的GIT的跨库同步方法,无法监控待同步GIT仓库的变化情况及时进行同步,导致GIT仓库的跨库同步效率较低
[0015]This invention embodiment cyclically acquires the commit information of the source database. After each acquisition of the source database's commit information, it determines whether the source database needs synchronization. When the source database needs synchronization, it uses the cross-database synchronization program to perform cross-database synchronization between the source and target databases based on the first and second synchronization connections. By cyclically acquiring the source database's commit information, the data changes in the source database can be monitored in a timely manner, thereby determining whether the source database needs synchronization and performing cross-database synchronization promptly, improving the efficiency of cross-database synchronization. Therefore, the Git-based cross-database synchronization method, apparatus, electronic device, and readable storage medium proposed in this invention embodiment improve the efficiency of Git-based cross-database synchronization.
Smart Images

Figure CN117851506B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to data synchronization technology, and more particularly to a cross-database synchronization method, apparatus, electronic device, and storage medium based on Git. Background Technology
[0002] To maintain code consistency across different code repositories and facilitate collaboration and version management, cross-repository synchronization between different Git repositories is often necessary.
[0003] However, existing cross-database synchronization methods for Git cannot monitor changes in the Git repository to be synchronized and synchronize them in a timely manner, resulting in low efficiency of cross-database synchronization of Git repositories. Summary of the Invention
[0004] This invention provides a Git-based cross-database synchronization method, apparatus, electronic device, and storage medium, the main purpose of which is to improve the efficiency of Git-based cross-database synchronization.
[0005] Respond to cross-database synchronization requests between the source and target databases, and obtain the source database address, source database authentication information, target database address, and target database authentication information; Based on the source database address and the source database authentication information, a preset cross-database synchronization program is constructed to establish a first synchronization connection with the source database, and based on the target database address and the target database authentication information, a second synchronization connection is constructed between the cross-database synchronization program and the target database. The commit information of the source database is obtained in a loop. After each acquisition of the commit information of the source database, it is determined whether the source database needs to be synchronized. When the source database needs to be synchronized, the cross-database synchronization program is used to perform cross-database synchronization between the source database and the target database based on the first synchronization connection and the second synchronization connection.
[0006] Optionally, determining whether the source repository needs to be synchronized based on the acquired commit information includes: Determine if the total number of all retrieved commit messages is 1; If the total number of commit messages obtained is 1, then the source library needs to be synchronized. If the total number of commit messages obtained is not 1, determine whether the latest obtained commit message is consistent with the last obtained commit message. If the latest commit information is inconsistent with the last commit information, the source library needs to be synchronized. If the latest commit information is the same as the last commit information, then the source repository does not need to be synchronized.
[0007] Optionally, the step of performing cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: The content in the source library is sent to the cross-library synchronization program through the first synchronization connection, and the content in the source library received by the cross-library synchronization program is determined as the relay synchronization content; The relay synchronization content is sent to the target database through the second synchronization connection to synchronize the relay synchronization content to the target database, thereby realizing cross-database synchronization between the source database and the target database.
[0008] Optionally, the step of performing cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: Obtain the range of branches in the source library that need to be synchronized; The branches contained in the source library within the specified branch range are identified as target branches; The contents of all branches in the source library are sent to the cross-library synchronization program through the first synchronization connection, and the contents of the source library received by the cross-library synchronization program are identified as the relay synchronization contents. The relay synchronization content is sent to the target database through the second synchronization connection to synchronize the relay synchronization content to the target database, thereby realizing cross-database synchronization between the source database and the target database.
[0009] Optionally, the loop to obtain the commit information of the source library includes: During the cross-database synchronization request and response, the commit information of the source database is continuously obtained, and the cross-database synchronization program is used to perform timed cross-database synchronization between the source database and the target database according to the first synchronization connection and the second synchronization connection.
[0010] Optionally, the step of performing timed cross-database synchronization of the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: Based on the first synchronization connection and the second synchronization connection, cross-database synchronization between the source database and the target database is performed periodically using the cross-database synchronization program at fixed synchronization time intervals.
[0011] To address the above problems, the present invention also provides a cross-database synchronization device based on Git, the device comprising: The data acquisition module is used to respond to cross-database synchronization requests between the source database and the target database, and to acquire the source database address, source database authentication information, target database address, and target database authentication information. The task execution module is used to execute all the target timed tasks and acquire the task execution result of each timed task. A connection building module is used to build a first synchronization connection between a preset cross-database synchronization program and the source database based on the source database address and the source database authentication information, and to build a second synchronization connection between the cross-database synchronization program and the target database based on the target database address and the target database authentication information; The cross-database synchronization module is used to repeatedly obtain the commit information of the source database. After obtaining the commit information of the source database each time, it determines whether the source database needs to be synchronized based on the obtained commit information. When the source database needs to be synchronized, the cross-database synchronization program is used to perform cross-database synchronization between the source database and the target database based on the first synchronization connection and the second synchronization connection.
[0012] Optionally, determining whether the source repository needs to be synchronized based on the acquired commit information includes: Determine if the total number of all retrieved commit messages is 1; If the total number of commit messages obtained is 1, then the source library needs to be synchronized. If the total number of commit messages obtained is not 1, determine whether the latest obtained commit message is consistent with the last obtained commit message. If the latest commit information is inconsistent with the last commit information, the source library needs to be synchronized. If the latest commit information is the same as the last commit information, then the source repository does not need to be synchronized.
[0013] To address the above problems, the present invention also provides an electronic device, the electronic device comprising: Memory, storing at least one computer program; and The processor executes the computer program stored in the memory to implement the Git-based cross-library synchronization method described above.
[0014] To address the aforementioned problems, the present invention also provides a computer-readable storage medium storing at least one computer program, which is executed by a processor in an electronic device to implement the aforementioned Git-based cross-library synchronization method.
[0015] This invention embodiment cyclically acquires the commit information of the source database. After each acquisition of the source database's commit information, it determines whether the source database needs synchronization. When the source database needs synchronization, it uses the cross-database synchronization program to perform cross-database synchronization between the source and target databases based on the first and second synchronization connections. By cyclically acquiring the source database's commit information, the data changes in the source database can be monitored in a timely manner, thereby determining whether the source database needs synchronization and performing cross-database synchronization promptly, improving the efficiency of cross-database synchronization. Therefore, the Git-based cross-database synchronization method, apparatus, electronic device, and readable storage medium proposed in this invention embodiment improve the efficiency of Git-based cross-database synchronization. Attached Figure Description
[0016] Figure 1 A flowchart illustrating a cross-database synchronization method based on Git provided in an embodiment of the present invention; Figure 2 A schematic diagram of a cross-database synchronization device based on Git provided in an embodiment of the present invention; Figure 3 A schematic diagram of the internal structure of an electronic device that implements a cross-library synchronization method based on Git, according to an embodiment of the present invention; The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0017] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0018] This invention provides a Git-based cross-database synchronization method. The execution entity of the Git-based cross-database synchronization method includes, but is not limited to, at least one of electronic devices, such as servers and terminals, that can be configured to execute the method provided in this application. In other words, the Git-based cross-database synchronization method can be executed by software or hardware installed on terminal devices or server devices, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster. The server can be an independent server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0019] Reference Figure 1The flowchart shown is a GIT-based cross-database synchronization method according to an embodiment of the present invention. In this embodiment, the GIT-based cross-database synchronization method includes: S1. Respond to the cross-database synchronization request between the source database and the target database, and obtain the source database address, source database authentication information, target database address, and target database authentication information; In this embodiment of the invention, the source repository is the Git code repository to be synchronized, the target repository is the Git code repository that synchronizes the content of the source repository, and the cross-repository synchronization request is a request that requires cross-repository synchronization between the source repository and the target repository.
[0020] Furthermore, in this embodiment of the invention, in order to facilitate cross-database synchronization between the source database and the target database, and to facilitate connection between the source database and the target database, the source database address, source database authentication information, target database address, and target database authentication information are obtained.
[0021] S2. Based on the source database address and the source database authentication information, a preset cross-database synchronization program is constructed and a first synchronization connection is established with the source database; and based on the target database address and the target database authentication information, a second synchronization connection is established between the cross-database synchronization program and the target database. In this embodiment of the invention, to avoid the source library and the target library being unable to connect directly, thus preventing cross-library synchronization, a preset cross-library synchronization program is constructed based on the source library address and the source library authentication information to connect with the source library (i.e., the first synchronization connection), and the cross-library synchronization program is constructed based on the target library address and the target library authentication information to connect with the target database (i.e., the second synchronization connection).
[0022] Furthermore, the construction of the first synchronous connection and the second synchronous connection in the embodiments of the present invention is a connection construction method commonly used by those skilled in the art, and will not be described in detail here.
[0023] The cross-database synchronization program described in this embodiment of the invention is a program capable of receiving and sending data, and capable of establishing connections with both the source and target databases. By using this cross-database synchronization program as a relay, the inability of the source and target databases to connect directly avoids synchronization failures, thus improving the stability and efficiency of cross-database synchronization.
[0024] S3. Loop through and obtain the commit information of the source database. After obtaining the commit information of the source database each time, determine whether the source database needs to be synchronized based on the obtained commit information. When the source database needs to be synchronized, perform cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection. In this embodiment of the invention, in order to determine whether the code in the source library has changed and whether synchronization is required, the commit information of the source library is obtained cyclically. After obtaining the commit information of the source library each time, it is determined whether the source library needs to be synchronized based on the obtained commit information.
[0025] It should be explained that, in this embodiment of the invention, the commit information is a piece of text in Git used to describe the changes made in each code commit. Therefore, the source repository can be determined whether it needs to be synchronized by obtaining the commit information.
[0026] Furthermore, since cross-database synchronization may fail when the content in the source database changes, in this embodiment of the invention, in addition to monitoring whether the content in the source database changes and timely cross-database synchronization, cross-database synchronization is also performed on the source database and the target database at regular intervals to avoid a single synchronization failure.
[0027] Specifically, in this embodiment of the invention, the cyclic acquisition of the commit information of the source library includes: During the cross-database synchronization request and response, the commit information of the source database is continuously obtained, and the cross-database synchronization program is used to perform timed cross-database synchronization between the source database and the target database according to the first synchronization connection and the second synchronization connection.
[0028] Furthermore, in this embodiment of the invention, the method of performing timed cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: Based on the first synchronization connection and the second synchronization connection, the source database and the target database are synchronized at fixed synchronization time intervals using the cross-database synchronization program.
[0029] It's important to explain that a cross-repository synchronization program can support the synchronization of dozens or even hundreds of code repositories. Active code synchronization is triggered periodically. To avoid a large number of code repositories synchronizing simultaneously, which would put immense pressure on the CPU and cause thread queuing, the synchronization time interval for each code repository is set to increase or decrease by 1% to 50% from a fixed time interval. Avoiding a large number of code repositories undergoing timed synchronization simultaneously ensures a more balanced distribution of thread execution, more balanced CPU scheduling, and higher thread synchronization efficiency.
[0030] In this embodiment of the invention, the content in the source repository is monitored for changes based on the acquired commit information, thereby determining whether the source repository needs to be synchronized. Specifically, determining whether the source repository needs to be synchronized based on the acquired commit information includes: Determine if the total number of all retrieved commit messages is 1; If the total number of commit messages obtained is 1, then the source library needs to be synchronized. If the total number of commit messages obtained is not 1, determine whether the latest obtained commit message is consistent with the last obtained commit message. If the latest commit information is inconsistent with the last commit information, the source library needs to be synchronized. If the latest commit information is the same as the last commit information, then the source repository does not need to be synchronized.
[0031] Optionally, in this embodiment of the invention, commit information can be obtained by calling the commit information interface of the source library.
[0032] In this embodiment of the invention, when the latest acquired commit information changes, it indicates that the code in the source library has changed and the content in the source library needs to be synchronized to the target database. Therefore, based on the first synchronization connection and the second synchronization connection, the cross-database synchronization program is used to perform cross-database synchronization between the source database and the target database.
[0033] In detail, the cross-database synchronization between the source database and the target database performed using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection in this embodiment of the invention includes: The content in the source library is sent to the cross-library synchronization program through the first synchronization connection, and the content in the source library received by the cross-library synchronization program is determined as the relay synchronization content; The relay synchronization content is sent to the target database through the second synchronization connection to synchronize the relay synchronization content to the target database, thereby realizing cross-database synchronization between the source database and the target database.
[0034] In another optional embodiment of the present invention, when synchronizing the source database, it is not necessary to synchronize the entire content of the source database, but only the content of certain branches in the source database that need to be synchronized. Therefore, the step of performing cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: Obtain the range of branches in the source library that need to be synchronized; The branches contained in the source library within the specified branch range are identified as target branches; The contents of all branches in the source library are sent to the cross-library synchronization program through the first synchronization connection, and the contents of the source library received by the cross-library synchronization program are identified as the relay synchronization contents. The relay synchronization content is sent to the target database through the second synchronization connection to synchronize the relay synchronization content to the target database, thereby realizing cross-database synchronization between the source database and the target database.
[0035] like Figure 2 The diagram shown is a functional block diagram of the cross-database synchronization device based on Git according to the present invention.
[0036] The Git-based cross-database synchronization device 100 described in this invention can be installed in an electronic device. Depending on the functions implemented, the Git-based cross-database synchronization device may include a data acquisition module 101, a connection construction module 102, and a cross-database synchronization module 103. The module described in this invention may also be referred to as a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and are stored in the memory of the electronic device.
[0037] In this embodiment, the functions of each module / unit are as follows: The data acquisition module 101 is used to respond to the cross-database synchronization request between the source database and the target database, and to acquire the source database address, source database authentication information, target database address, and target database authentication information. The task execution module is used to execute all the target timed tasks and acquire the task execution result of each timed task. The connection building module 102 is used to build a first synchronization connection between a preset cross-database synchronization program and the source database based on the source database address and the source database authentication information, and to build a second synchronization connection between the cross-database synchronization program and the target database based on the target database address and the target database authentication information; The cross-database synchronization module 103 is used to cyclically obtain the commit information of the source database. After obtaining the commit information of the source database each time, it determines whether the source database needs to be synchronized based on the obtained commit information. When the source database needs to be synchronized, it uses the cross-database synchronization program to perform cross-database synchronization between the source database and the target database based on the first synchronization connection and the second synchronization connection.
[0038] In detail, the modules in the Git-based cross-database synchronization device 100 described in this embodiment of the invention employ the same methods as described above. Figure 1 The method uses the same technical means as the Git-based cross-database synchronization method described in the previous section and can produce the same technical effect, so it will not be repeated here.
[0039] like Figure 3 The diagram shown is a schematic representation of the electronic device that implements the cross-library synchronization method based on Git according to the present invention.
[0040] The electronic device may include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a Git-based cross-library synchronization program.
[0041] The memory 11 includes at least one type of readable storage medium, such as flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a portable hard drive. In other embodiments, the memory 11 can be an external storage device of the electronic device, such as a plug-in portable hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. Furthermore, the memory 11 can include both internal and external storage units of the electronic device. The memory 11 can be used not only to store application software and various types of data installed on the electronic device, such as the code of a Git-based cross-library synchronization program, but also to temporarily store data that has been output or will be output.
[0042] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., cross-library synchronization programs based on Git), and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0043] The communication bus 12 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. The communication bus 12 is configured to enable communication between the memory 11 and at least one processor 10, etc. For ease of illustration, only one thick line is used in the figure, but this does not indicate that there is only one bus or one type of bus.
[0044] Figure 3 Only electronic devices with components are shown; those skilled in the art will understand that... Figure 3 The structure shown does not constitute a limitation on the electronic device and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0045] For example, although not shown, the electronic device may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault classification circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0046] Optionally, the communication interface 13 may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, a Bluetooth interface, etc.), which is typically used to establish communication connections between the electronic device and other electronic devices.
[0047] Optionally, the communication interface 13 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired or wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device and to display a visual user interface.
[0048] It should be understood that the embodiments described are for illustrative purposes only and are not limited to this structure in the scope of the patent application.
[0049] The memory 11 in the electronic device stores a Git-based cross-library synchronization program, which is a combination of multiple computer programs. When run in the processor 10, it can achieve the following: Respond to cross-database synchronization requests between the source and target databases, and obtain the source database address, source database authentication information, target database address, and target database authentication information; Based on the source database address and the source database authentication information, a preset cross-database synchronization program is constructed to establish a first synchronization connection with the source database, and based on the target database address and the target database authentication information, a second synchronization connection is constructed between the cross-database synchronization program and the target database. The commit information of the source database is obtained in a loop. After each acquisition of the commit information of the source database, it is determined whether the source database needs to be synchronized. When the source database needs to be synchronized, the cross-database synchronization program is used to perform cross-database synchronization between the source database and the target database based on the first synchronization connection and the second synchronization connection.
[0050] Specifically, the processor 10's implementation method of the above-mentioned computer program can be found in [reference needed]. Figure 1 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.
[0051] Furthermore, if the modules / units integrated into the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable medium can be non-volatile or volatile. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0052] Embodiments of the present invention may also provide a computer-readable storage medium storing a computer program, which, when executed by a processor of an electronic device, can perform the following: Respond to cross-database synchronization requests between the source and target databases, and obtain the source database address, source database authentication information, target database address, and target database authentication information; Based on the source database address and the source database authentication information, a preset cross-database synchronization program is constructed to establish a first synchronization connection with the source database, and based on the target database address and the target database authentication information, a second synchronization connection is constructed between the cross-database synchronization program and the target database. The commit information of the source database is obtained in a loop. After each acquisition of the commit information of the source database, it is determined whether the source database needs to be synchronized. When the source database needs to be synchronized, the cross-database synchronization program is used to perform cross-database synchronization between the source database and the target database based on the first synchronization connection and the second synchronization connection.
[0053] Furthermore, the computer's usable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store the operating system, applications required for at least one function, etc.; and the data storage area may store data created based on the use of blockchain nodes, etc.
[0054] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0055] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0056] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0057] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0058] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0059] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.
[0060] The blockchain referred to in this invention is an application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0061] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. The term "second class" is used to indicate names and does not indicate any specific order.
[0062] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A cross-database synchronization method based on Git, characterized in that, The method includes: Respond to cross-database synchronization requests between the source and target databases, and obtain the source database address, source database authentication information, target database address, and target database authentication information; Based on the source database address and the source database authentication information, a preset cross-database synchronization program is constructed to establish a first synchronization connection with the source database, and based on the target database address and the target database authentication information, a second synchronization connection is constructed between the cross-database synchronization program and the target database. The commit information of the source database is obtained in a loop. After each acquisition of the commit information of the source database, it is determined whether the source database needs to be synchronized based on the acquired commit information. When the source database needs to be synchronized, cross-database synchronization between the source database and the target database is performed using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection. The step of determining whether the source library needs to be synchronized based on the acquired commit information includes: determining whether the total number of acquired commit information is 1; if the total number of acquired commit information is 1, then the source library needs to be synchronized; if the total number of acquired commit information is not 1, determining whether the latest acquired commit information is consistent with the previously acquired commit information; if the latest acquired commit information is inconsistent with the previously acquired commit information, then the source library needs to be synchronized; if the latest acquired commit information is consistent with the previously acquired commit information, then the source library does not need to be synchronized.
2. The cross-database synchronization method based on Git as described in claim 1, characterized in that, The step of performing cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: The content in the source library is sent to the cross-library synchronization program through the first synchronization connection, and the content in the source library received by the cross-library synchronization program is determined as the relay synchronization content; The relay synchronization content is sent to the target database through the second synchronization connection to synchronize the relay synchronization content to the target database, thereby realizing cross-database synchronization between the source database and the target database.
3. The cross-database synchronization method based on Git as described in claim 1, characterized in that, The step of performing cross-database synchronization between the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: Obtain the range of branches in the source library that need to be synchronized; The branches contained in the source library within the branch range are identified as target branches; The contents of all branches in the source library are sent to the cross-library synchronization program through the first synchronization connection, and the contents of the source library received by the cross-library synchronization program are identified as the relay synchronization contents. The relay synchronization content is sent to the target database through the second synchronization connection to synchronize the relay synchronization content to the target database, thereby realizing cross-database synchronization between the source database and the target database.
4. The cross-database synchronization method based on Git as described in claim 1, characterized in that, The loop that retrieves the commit information of the source library includes: During the cross-database synchronization request and response, the commit information of the source database is continuously obtained, and the cross-database synchronization program is used to perform timed cross-database synchronization between the source database and the target database according to the first synchronization connection and the second synchronization connection.
5. The cross-database synchronization method based on Git as described in claim 4, characterized in that, The step of performing timed cross-database synchronization of the source database and the target database using the cross-database synchronization program based on the first synchronization connection and the second synchronization connection includes: Based on the first synchronization connection and the second synchronization connection, cross-database synchronization between the source database and the target database is performed periodically using the cross-database synchronization program at fixed synchronization time intervals.
6. A cross-database synchronization device based on Git, characterized in that, include: The data acquisition module is used to respond to cross-database synchronization requests between the source database and the target database, and to acquire the source database address, source database authentication information, target database address, and target database authentication information. The task execution module is used to execute all the target timed tasks and acquire the task execution result of each timed task. A connection building module is used to build a first synchronization connection between a preset cross-database synchronization program and the source database based on the source database address and the source database authentication information, and to build a second synchronization connection between the cross-database synchronization program and the target database based on the target database address and the target database authentication information; The cross-database synchronization module is used to repeatedly obtain the commit information of the source database. After obtaining the commit information of the source database each time, it determines whether the source database needs to be synchronized based on the obtained commit information. When the source database needs to be synchronized, it uses the cross-database synchronization program to perform cross-database synchronization between the source database and the target database based on the first synchronization connection and the second synchronization connection. The step of determining whether the source library needs to be synchronized based on the acquired commit information includes: determining whether the total number of acquired commit information is 1; if the total number of acquired commit information is 1, then the source library needs to be synchronized; if the total number of acquired commit information is not 1, determining whether the latest acquired commit information is consistent with the previously acquired commit information; if the latest acquired commit information is inconsistent with the previously acquired commit information, then the source library needs to be synchronized; if the latest acquired commit information is consistent with the previously acquired commit information, then the source library does not need to be synchronized.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory that is communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, which is then executed by the at least one processor to enable the at least one processor to perform the GIT-based cross-library synchronization method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the Git-based cross-library synchronization method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Database data synchronous parallel execution method and device based on asynchronous submission
CN109657007A
Data synchronization method and device, and server
CN110309161A