CN112035495A - Data synchronization method, device, server and storage medium - Google Patents
Data synchronization method, device, server and storage medium Download PDFInfo
- Publication number
- CN112035495A CN112035495A CN202010842220.4A CN202010842220A CN112035495A CN 112035495 A CN112035495 A CN 112035495A CN 202010842220 A CN202010842220 A CN 202010842220A CN 112035495 A CN112035495 A CN 112035495A
- Authority
- CN
- China
- Prior art keywords
- updating
- data
- cache
- update
- failure
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 60
- 238000004590 computer program Methods 0.000 claims description 12
- 238000010586 diagram Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention discloses a data synchronization method, a data synchronization device, a server and a storage medium. The method comprises the following steps: receiving an information updating request, wherein the information updating request comprises first updating data; writing the first updating data into a second server serving as a database according to the information updating request; generating an update cache instruction based on the first update data; and executing an update cache instruction based on the received update triggering event, and updating the first update data to a third server serving as a cache. The embodiment of the invention ensures that the data in the cache is consistent with the data in the database, and avoids the phenomena of dirty reading of the data and the like.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data synchronization method, apparatus, server, and storage medium.
Background
The system caches the database data by introducing the cache component, preferentially searches the cache data when the system queries the data, and clears/updates the cache data when the data is changed, so that the aim of relieving the pressure of the database at the back end of the system is fulfilled. In the prior art, when data in a database and a cache are updated and read, the situation that the data in the database and the data in the cache are inconsistent before a database transaction is submitted easily occurs.
Disclosure of Invention
In view of this, embodiments of the present invention provide a data synchronization method, an apparatus, a server, and a storage medium, so as to implement synchronous update of data in a database and data in a cache.
In a first aspect, an embodiment of the present invention provides a data synchronization method, including:
receiving an information updating request, wherein the information updating request comprises first updating data;
writing the first updating data into a second server serving as a database according to the information updating request;
generating an update cache instruction based on the first update data;
and executing the updating cache instruction based on the received updating triggering event, and updating the first updating data to a third server serving as a cache.
In a second aspect, an embodiment of the present invention further provides a data synchronization apparatus, including:
an information updating request receiving module, configured to receive an information updating request, where the information updating request includes first updating data;
the server updating module is used for writing the first updating data into a second server serving as a database according to the information updating request;
the updating cache instruction generating module is used for generating an updating cache instruction based on the first updating data;
and the cache updating module is used for executing the cache updating instruction based on the received updating triggering event and updating the first updating data to a third server serving as a cache.
In a third aspect, an embodiment of the present invention further provides a server, including a memory and a processor, where the memory stores a computer program executable by the processor, and the processor implements the data synchronization method as described above when executing the computer program.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the data synchronization method as described above.
According to the technical scheme provided by the embodiment of the invention, first updating data is written into a second server serving as a database according to a received information updating request, and an updating cache instruction is generated based on the first updating data; and executing the cache updating instruction based on the received updating triggering event, updating the first updating data to the database, and updating the first updating data to a third server serving as a cache, so that the data in the cache is consistent with the data in the database, and the phenomena of dirty reading of the data and the like are avoided.
Drawings
FIG. 1 is a flow chart of a data synchronization method according to a first embodiment of the present invention;
FIG. 2 is a flow chart of a data synchronization method according to a first embodiment of the present invention;
FIG. 3 is a sub-flowchart of a data synchronization method according to a second embodiment of the present invention;
FIG. 4 is a sub-flowchart of a data synchronization method according to a second embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a data synchronization apparatus according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of a server in the fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the steps as a sequential process, many of the steps can be performed in parallel, concurrently or simultaneously. In addition, the order of the steps may be rearranged. A process may be terminated when its operations are completed, but may have additional steps not included in the figure. A process may correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
Furthermore, the terms "first," "second," and the like may be used herein to describe various orientations, actions, steps, elements, or the like, but the orientations, actions, steps, or elements are not limited by these terms. These terms are only used to distinguish one direction, action, step or element from another direction, action, step or element. The terms "first", "second", etc. are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present invention, "plurality", "batch" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Example one
Fig. 1 is a flowchart of a data synchronization method according to a first embodiment of the present invention, where the present embodiment is applied to a distributed storage system, the storage system includes a first server with a service system, a second server serving as a database, and a third server serving as a cache.
The example procedure is as follows:
s110, receiving an information updating request, wherein the information updating request comprises first updating data.
The information updating request is sent by the user terminal, and specifically, the request is initiated by an updating interface of the service system called by the user. The information updating request comprises target information needing to be updated and corresponding updating data, and the updating data is used for replacing the stored data in the database. Each information update request may include one or more target information and corresponding one or more update data. The first update data is one of the update data.
And S120, writing the first updating data into a second server serving as a database according to the information updating request.
The second server is used as a database in this embodiment, and the database stores corresponding stored data in advance, and for the convenience of distinguishing, for the first updated data, the first stored data is stored in the database correspondingly in advance.
After receiving the information updating request, the first server directly writes the first updating data in the information updating request into the database, namely, the second server. At this time, the first update data in the database does not replace the first storage data, that is, the first update data and the first storage data are simultaneously stored in the database, and at this time, when the database is queried, the query result provided by the server is the first storage data.
And S130, generating an updating cache instruction based on the first updating data.
The update cache instruction is generated by a cache transaction hook (CacheTransactionSynchronization hook) for updating the first update data to the cache. The update cache instruction is stored in a first server, such as a memory of the first server.
The first server, upon receiving the information update request, may generate an update cache instruction based on the first update data after writing the first update data to the second server as the database.
S140, executing the update cache instruction based on the received update trigger event, and updating the first update data to a third server serving as a cache.
The update triggering event is a transaction commit operation, which may be issued by the client, indicating that the client determines to complete data update to the server.
In this embodiment, the third server is configured to serve as a cache of the server, and specifically, a memory of the third server may be used as the cache, where the first storage data that is the same as the database is stored in the cache. After receiving the update trigger event, the first server directly executes the update cache instruction, and updates the first update data to the cache, that is, updates the first storage data in the cache to the first update data. Before that, the first stored data in the database is updated to the first updated data based on the update triggering event, so as to keep the data in the database and the data in the cache consistent.
More specifically, in an embodiment, after step S110, step S111 (not shown) is further included:
s111, checking whether a cache transaction hook is registered or not, if not, registering the cache transaction hook, wherein the cache transaction hook is used for generating an update cache instruction according to the first update data.
The cache transaction hook is used to generate an update cache instruction, and if the cache transaction hook is not registered, the update cache instruction cannot be generated, so that after the first server receives the information update request, if the cache transaction hook is detected to be unregistered, the cache transaction hook needs to be registered first, and step S111 should be before step S130.
Specifically, in an example, the requester a calls an update interface of the service system, and sends a first update request for updating the information a to the first server, where the first update request includes first update data a 1; the first server writes first update data A1 into a database, for example, data of information A is updated by a dao (data Access object) method, an update cache instruction I is generated by a CacheTransactionSynchronization hook, and the update cache instruction I is stored to threaded local of CacheTransactionSynchronization, and at this time, the first update data A2 is obtained by the database and the cache query information A; after receiving an update triggering event, the first server triggers a cachetransaction synchronization hook before-copy method, marks a failure flag true in the before-copy method, sets a failure expiration time, updates first storage data a2 corresponding to information a in the database to first update data a1, then executes an update cache instruction I in the after-copy method, updates the first update data a1 to a cache, and sets the failure flag to false. After the updating, the first updating data a1 is obtained by querying the information a through the database and the cache.
In the technical solution of the first embodiment, the first update data is written into the second server serving as the database according to the received information update request, and an update cache instruction is generated based on the first update data; and executing the cache updating instruction based on the received updating triggering event, updating the first updating data to the database, and updating the first updating data to a third server serving as a cache, so that the data in the cache is consistent with the data in the database, and the phenomena of dirty reading of the data and the like are avoided.
Example two
In this embodiment, a part of the content is further supplemented on the basis of the first embodiment, and by setting the first expiration flag and the expiration validity period, the cache update failure is avoided from being discovered in time, specifically as shown in fig. 2, after the step S130, the method further includes a step S210, and after the step S140, the method further includes a step S220:
s110, receiving an information updating request, wherein the information updating request comprises first updating data.
And S120, writing the first updating data into a second server serving as a database according to the information updating request.
And S130, generating an updating cache instruction based on the first updating data.
S210, generating a corresponding first invalidation identification and invalidation validity period based on the cache updating instruction.
The first invalidation flag is used to indicate that the data in the cache has not been updated, and may also be understood to indicate that the data in the cache is not used as a query result. The expiration validity period is used for judging whether the execution of the cache instruction is finished, namely whether the first updating data is updated to the cache or not, when the expiration validity period is expired, the cache instruction is executed, the data in the cache is updated, the first expiration identifier needs to be changed, when the expiration validity period is not expired, the data in the cache is not updated, and the first expiration identifier does not need to be changed. The expiration validity period is generally set according to the time consumption required for completing the cache update instruction, so as to accurately judge whether the first expiration identifier is changed. The expiration date may also be set to a default value in an alternative embodiment.
When the first server generates the updating cache instruction, a first invalidation identifier and an invalidation validity period corresponding to the updating cache instruction are generated.
S140, executing the update cache instruction based on the received update trigger event, and updating the first update data to a third server serving as a cache.
S220, after the expiration validity period is determined to be expired based on the updating triggering event, the first expiration identifier is changed into a second expiration identifier.
Whether the expiration validity period is expired or not is determined by both the renewal trigger event and the expiration validity period, and the expiration validity period is determined when the elapsed time length is equal to the expiration validity period from the time when the renewal trigger event is received. For example, if the expiration date is 5 seconds and the time when the update trigger event is received is 10 minutes and 15 seconds, the expiration date is determined to have expired at 10 minutes and 20 seconds. And changing the first failure identifier into a second failure identifier after the failure validity period is determined to be over. The second invalidation identifier is used for identifying that the cache is updated, and the data in the cache can be used as a query result. The second failure flag is opposite to the first failure flag, and illustratively, the first failure flag is true, the second failure flag is false, and the aft completion method of cachetransfactionsynchronization is executed when changing, so that true is changed into false.
The first server directly executes the cache updating instruction after receiving the updating triggering event, determines whether the failure validity period is expired, and changes the first failure identifier into the second failure identifier after determining that the failure validity period is expired.
An update trigger event indicates that a data update can be successfully completed, while in some cases, a data update cannot be successfully completed, i.e., an update rollback occurs. In an alternative embodiment, the specific rollback procedure is to replace step S140 in fig. 2 with step S150 (not shown):
s150, deleting the first updating data in the database based on the received rollback triggering event, deleting the updating cache instruction, and changing the first failure identifier into a second failure identifier.
The rollback triggering event may be issued by the user side or by the database (second server). When the data is sent from the user side, the data updating is terminated for the user, the first updating data is selected not to be stored in the database, and when the data is sent from the database, the data updating is generally caused by abnormal updating. When the first server receives the rollback triggering event, the first server deletes the first updating data written into the database, deletes the updating cache instructions stored in the first server, and changes the first failure identifier into the second failure identifier.
The data synchronization method shown in fig. 1 and fig. 2 is a data updating process, and on the basis, a data querying process is correspondingly provided, and the data querying process is shown in fig. 3 and fig. 4, where fig. 3 shows the data querying process in a case where the cache does not complete the updating, and fig. 4 shows the data querying process after the cache completes the updating.
Specifically, as shown in fig. 3 in one embodiment, after S210, the method further includes S230-260:
and S230, receiving an information inquiry request.
In this embodiment, the information query request and the information update request are corresponding and both point to the same target information, for example, the information update request is used to update the information a, and the information query request is used to query the information a.
S240, verifying the corresponding current failure identification and the failure validity period according to the information query request.
After receiving the information query request, the first terminal determines whether the current failure identifier corresponding to the information query request is a first failure identifier or a second failure identifier. And if the first failure identification is the first failure identification, inquiring corresponding data from the database as an inquiry result, and if the second failure identification is the second failure identification, inquiring corresponding data from the cache as an inquiry result. And under the condition that the current invalidation identifier is the first invalidation identifier, whether the corresponding invalidation validity period is expired or not needs to be judged, if so, the first server fails when the cache updating instruction is executed, and if not, the first server fails, the other users update the corresponding data.
S250, if the current failure identifier is the first failure identifier and the failure validity period is not expired, acquiring corresponding first storage data from a database as a query result.
When the current failure identifier is the first failure identifier and the expiration date is not expired, the data in the cache may be updating, and at this time, the data in the cache is read as the query result, which may not be consistent with the data in the database, and the data in the database is determined, so that the first stored data in the database is directly read as the query result.
S260, if the current failure identifier is the first failure identifier and the expiration validity period is expired, acquiring corresponding first updating data from a database as a query result, and updating corresponding first storage data in a cache into the first updating data.
When the current failure identifier is the first failure identifier and the expiration date has expired, it indicates that the first server has received the update triggering event, but the data in the cache is not updated due to a failure (e.g., downtime) of the first server and the like, and at this time, the data in the cache may be erroneous, and the cache should be repaired after the data update in the database has been completed. Therefore, the corresponding first updating data is obtained from the database as a query result, and the corresponding first storage data in the cache is updated to the first updating data.
Specifically, as shown in fig. 4 in one embodiment, step S220 is followed by steps S270-280:
s270, receiving an information inquiry request.
In this embodiment, the information query request and the information update request are corresponding and both point to the same target information, for example, the information update request is used to update the information a, and the information query request is used to query the information a
S280, verifying the current failure identification according to the information query request, and if the current failure identification is the second failure identification, acquiring first updating data from a cache as a query result.
When the current invalidation identifier is that the second invalidation identifier is updated, that is, the updated data (first updated data) is stored in the cache, the data in the cache can be directly read to reduce the pressure of the database, so that the first updated data can be obtained from the cache as a query result according to the information query request.
In the data synchronization method provided by this embodiment, a data query process is further added on the basis of the first embodiment, a query result is obtained from the database or the cache query data according to the current cache identifier and the cache expiration date, and it can be determined that an error occurs when the service system updates the cache according to the expiration date of the expiration identifier and the current expiration identifier being the first expiration identifier, thereby effectively avoiding a cache data error caused by a service system failure.
EXAMPLE III
Fig. 5 is a data synchronization apparatus 300 according to a third embodiment of the present invention, which specifically includes the following modules:
an information update request receiving module 310, configured to receive an information update request, where the information update request includes first update data;
a server update module 320, configured to write the first update data into a second server serving as a database according to the information update request;
an update cache instruction generating module 330, configured to generate an update cache instruction based on the first update data;
and a cache updating module 340, configured to execute the update cache instruction based on the received update trigger event, and update the first update data to a third server serving as a cache.
More specifically, in an embodiment, the apparatus further includes a hook registration module, configured to check whether a cache transaction hook has been registered, and if not, register the cache transaction hook, where the cache transaction hook is configured to generate an update cache instruction according to the first update data; more specifically, the server updating module 320 is further configured to update the first stored data in the database to the first updated data based on the update triggering event after executing the update caching instruction based on the received update triggering event.
More specifically, in an embodiment, the method further includes:
the invalidation identifier generating module is used for generating a corresponding first invalidation identifier and invalidation validity period based on the cache updating instruction;
and the failure identifier changing module is used for changing the first failure identifier into a second failure identifier after the expiration of the failure validity period is determined based on the updating triggering event.
More specifically, in an embodiment, the system further includes an information query request receiving module, a failure identifier verifying module, and a query feedback module:
and the information query request receiving module is used for receiving the information query request.
And the failure identifier verification module is used for verifying the corresponding current failure identifier and the failure validity period according to the information inquiry request.
The query feedback module is used for acquiring corresponding first storage data from a database as a query result if the current failure identifier is the first failure identifier and the failure validity period is not expired; and if the current failure identifier is the first failure identifier and the expiration date is expired, acquiring corresponding first updating data from a database as a query result, and updating corresponding first stored data in the cache into the first updating data.
More specifically, in one embodiment, the query feedback module is further configured to: and verifying the current failure identification according to the information query request, and if the current failure identification is the second failure identification, acquiring first updating data from a cache as a query result.
More specifically, in an embodiment, the method further includes:
and the rollback module is used for deleting the first updating data in the database based on the received rollback triggering event, deleting the updating cache instruction and changing the first failure identifier into a second failure identifier.
The data synchronization apparatus provided in this embodiment writes first update data into a second server serving as a database according to a received information update request, and generates an update cache instruction based on the first update data; and executing the cache updating instruction based on the received updating triggering event, updating the first updating data to the database, and updating the first updating data to a third server serving as a cache, so that the data in the cache is consistent with the data in the database, and the phenomena of dirty reading of the data and the like are avoided.
Example four
Fig. 6 is a schematic structural diagram of a server according to a fourth embodiment of the present invention, as shown in fig. 6, the server includes a processor 40, a memory 41, an input device 42, and an output device 43; the number of the processors 40 in the server can be one or more, and one processor 40 is taken as an example in the figure; the processor 40, the memory 41, the input device 42 and the output device 43 in the server may be connected by a bus or other means, and the bus connection is exemplified in fig. 4.
The memory 41 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the data synchronization method in the embodiment of the present invention (for example, the information update request receiving module 310, the server updating module 320, the update cache instruction generating module 330, and the cache updating module 340 in the data synchronization apparatus). The processor 40 executes various functional applications of the terminal/server and data processing by running software programs, instructions and modules stored in the memory 41, that is, implements the above-described data synchronization method.
Wherein the processor 40 is configured to run a computer executable program stored in the memory 41 to implement the following steps:
receiving an information updating request, wherein the information updating request comprises first updating data;
writing the first updating data into a second server serving as a database according to the information updating request;
generating an update cache instruction based on the first update data;
and executing the updating cache instruction based on the received updating triggering event, and updating the first updating data to a third server serving as a cache.
The memory 41 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 41 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, memory 41 may further include memory located remotely from processor 40, which may be connected to a terminal/server through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 42 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the terminal/server. The output device 43 may include a display device such as a display screen.
Of course, the server provided in the embodiment of the present invention is not limited to execute the method operations described above, and may also execute the related operations in the data synchronization method provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
EXAMPLE five
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a data synchronization method provided in any embodiment of the present invention, where the method may include:
receiving an information updating request, wherein the information updating request comprises first updating data;
writing the first updating data into a second server serving as a database according to the information updating request;
generating an update cache instruction based on the first update data;
and executing the updating cache instruction based on the received updating triggering event, and updating the first updating data to a third server serving as a cache.
More specifically, in some embodiments, the program, when executed by the processor, may further implement:
after the updating cache instruction is generated based on the first updating data, the method further comprises the following steps:
generating a corresponding first failure identification and a corresponding failure validity period based on the cache updating instruction;
after the writing the first update data to the third server as a cache, the method further includes:
changing the first failure identifier to a second failure identifier after determining that the expiration date has expired based on the update triggering event.
The computer-readable storage media of embodiments of the invention may take any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a storage medium may be transmitted over any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, or the like, as well as conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or terminal. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments illustrated herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1. A data synchronization method is applied to a first server, and is characterized by comprising the following steps:
receiving an information updating request, wherein the information updating request comprises first updating data;
writing the first updating data into a second server serving as a database according to the information updating request;
generating an update cache instruction based on the first update data;
and executing the updating cache instruction based on the received updating triggering event, and updating the first updating data to a third server serving as a cache.
2. The data synchronization method according to claim 1, wherein after receiving the information update request, further comprising:
checking whether a cache transaction hook is registered or not, if not, registering the cache transaction hook, wherein the cache transaction hook is used for generating an update cache instruction according to first update data;
after the updating the cache instruction is executed based on the received updating triggering event, the method further comprises the following steps:
updating first stored data in the database to the first updated data based on the update triggering event.
3. The data synchronization method according to claim 1, further comprising, after generating an update cache instruction based on the first update data:
generating a corresponding first failure identification and a corresponding failure validity period based on the cache updating instruction;
after the writing the first update data to the third server as a cache, the method further includes:
changing the first failure identifier to a second failure identifier after determining that the expiration date has expired based on the update triggering event.
4. The data synchronization method according to claim 3, further comprising, after generating the corresponding first invalidation identifier and invalidation validity period based on the update cache instruction:
receiving an information query request;
verifying the corresponding current failure identification and the failure validity period according to the information query request;
if the current failure identifier is the first failure identifier and the failure validity period is not expired, acquiring corresponding first storage data from a database as a query result;
and if the current failure identifier is the first failure identifier and the expiration date is expired, acquiring corresponding first updating data from a database as a query result, and updating corresponding first stored data in the cache into the first updating data.
5. The data synchronization method according to claim 3, wherein after the changing the first failure flag to the second failure flag, further comprising:
receiving an information query request;
and verifying the current failure identification according to the information query request, and if the current failure identification is the second failure identification, acquiring first updating data from a cache as a query result.
6. The data synchronization method according to claim 3, further comprising, after generating the corresponding first invalidation identifier and invalidation validity period based on the update cache instruction:
and deleting the first updating data in the database based on the received rollback triggering event, deleting the updating cache instruction, and changing the first invalidation identifier into a second invalidation identifier.
7. A data synchronization apparatus, comprising:
an information updating request receiving module, configured to receive an information updating request, where the information updating request includes first updating data;
the server updating module is used for writing the first updating data into a second server serving as a database according to the information updating request;
the updating cache instruction generating module is used for generating an updating cache instruction based on the first updating data;
and the cache updating module is used for executing the cache updating instruction based on the received updating triggering event and updating the first updating data to a third server serving as a cache.
8. The data synchronization apparatus according to claim 7, further comprising:
the invalidation identifier generating module is used for generating a corresponding first invalidation identifier and invalidation validity period based on the cache updating instruction;
and the failure identifier changing module is used for changing the first failure identifier into a second failure identifier after the expiration of the failure validity period is determined based on the updating triggering event.
9. A server, characterized by comprising a memory and a processor, the memory having stored thereon a computer program executable on the processor, the processor implementing the data synchronization method according to any one of claims 1-6 when executing the computer program.
10. A computer-readable storage medium, which stores a computer program, characterized in that the computer program, when being executed by a processor, implements the data synchronization method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010842220.4A CN112035495B (en) | 2020-08-20 | 2020-08-20 | Data synchronization method, device, server and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010842220.4A CN112035495B (en) | 2020-08-20 | 2020-08-20 | Data synchronization method, device, server and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112035495A true CN112035495A (en) | 2020-12-04 |
CN112035495B CN112035495B (en) | 2024-02-23 |
Family
ID=73578317
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010842220.4A Active CN112035495B (en) | 2020-08-20 | 2020-08-20 | Data synchronization method, device, server and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112035495B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115134134A (en) * | 2022-06-23 | 2022-09-30 | 中国民航信息网络股份有限公司 | Information processing method, device and equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104156361A (en) * | 2013-05-13 | 2014-11-19 | 阿里巴巴集团控股有限公司 | Method and system for achieving data synchronization |
CN105956032A (en) * | 2016-04-25 | 2016-09-21 | 百度在线网络技术(北京)有限公司 | Cache data synchronization method, system and apparatus |
CN108874882A (en) * | 2018-05-04 | 2018-11-23 | 广州四九游网络科技有限公司 | A kind of data processing method of THINKPHP frame |
CN109284305A (en) * | 2018-08-23 | 2019-01-29 | 阿里巴巴集团控股有限公司 | A kind of update method of data, apparatus and system |
CN109800272A (en) * | 2019-02-25 | 2019-05-24 | 广州虎牙信息科技有限公司 | Data cached synchronous method, server, application system and storage device |
-
2020
- 2020-08-20 CN CN202010842220.4A patent/CN112035495B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104156361A (en) * | 2013-05-13 | 2014-11-19 | 阿里巴巴集团控股有限公司 | Method and system for achieving data synchronization |
CN105956032A (en) * | 2016-04-25 | 2016-09-21 | 百度在线网络技术(北京)有限公司 | Cache data synchronization method, system and apparatus |
CN108874882A (en) * | 2018-05-04 | 2018-11-23 | 广州四九游网络科技有限公司 | A kind of data processing method of THINKPHP frame |
CN109284305A (en) * | 2018-08-23 | 2019-01-29 | 阿里巴巴集团控股有限公司 | A kind of update method of data, apparatus and system |
CN109800272A (en) * | 2019-02-25 | 2019-05-24 | 广州虎牙信息科技有限公司 | Data cached synchronous method, server, application system and storage device |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115134134A (en) * | 2022-06-23 | 2022-09-30 | 中国民航信息网络股份有限公司 | Information processing method, device and equipment |
Also Published As
Publication number | Publication date |
---|---|
CN112035495B (en) | 2024-02-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10474645B2 (en) | Automatically retrying transactions with split procedure execution | |
CN108647357B (en) | Data query method and device | |
CN108595505B (en) | Data query method and device | |
CN112052264B (en) | Business data query method and device, electronic equipment and readable storage medium | |
CN107368513B (en) | Method and device for updating client database | |
CN112613993A (en) | Transaction data processing method and device, computer equipment and storage medium | |
CN115729912A (en) | Database access system, database access method, computer device, and storage medium | |
CN112035495B (en) | Data synchronization method, device, server and storage medium | |
US20150169356A1 (en) | Transaction processing system | |
CN114036195A (en) | Data request processing method, device, server and storage medium | |
WO2021147773A1 (en) | Data processing method and apparatus, electronic device and computer-readable storage medium | |
US9317432B2 (en) | Methods and systems for consistently replicating data | |
CN115374133A (en) | Data processing method and device, electronic equipment and computer readable storage medium | |
CN116010926A (en) | Login authentication method, login authentication device, computer equipment and storage medium | |
CN111782721B (en) | Data synchronization method and device, electronic equipment and storage medium | |
CN108614868B (en) | Automatic database upgrading method | |
CN113553488A (en) | Method and device for updating index data in search engine, electronic equipment and medium | |
CN112286992B (en) | Query method, distributed system, device and storage medium | |
CN110609790A (en) | Analytic program test method, device, medium and computer equipment | |
CN110784479B (en) | Data verification method and device, electronic equipment and storage medium | |
CN110837536B (en) | Information processing method, device and storage medium | |
CN114647652A (en) | Data extraction method and device, electronic equipment and computer readable medium | |
US20050108194A1 (en) | System for verifying a state of an environment | |
CN118689940A (en) | Data processing method, device, server, storage medium and program product | |
CN114676165A (en) | Data query method and device, electronic equipment and computer readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |