A data processing method and device, electronic equipment and storage medium

By determining the processing order of cache and database based on caching patterns in the big data platform, the problem of data inconsistency between cache and database is solved, ensuring data consistency and system reliability.

CN112948409BActive Publication Date: 2026-04-10CHINA CONSTRUCTION BANK
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2021-03-31
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In big data platforms, inconsistencies between cached and database data can occur due to factors such as network instability, hardware errors, or application anomalies, which can affect the correctness of system functions. In particular, in financial transaction systems, inconsistencies between cached and database data exceeding one second are not allowed.

Method used

When receiving data processing instructions, the processing order of the cache and the database is determined according to the caching mode, and the processing operations are performed sequentially to ensure the consistency between the cached data and the database data.

Benefits of technology

This system ensures consistency between cached data and database data under different caching modes, avoiding data inconsistency issues caused by network instability or hardware errors, and improving the reliability and correctness of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112948409B_ABST
    Figure CN112948409B_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to the technical field of big data, and disclose a data processing method and device, electronic equipment and a storage medium, the method comprising: when a data processing instruction is received, determining a processing order of a cache and a database according to the data processing instruction and a cache mode; and performing a processing operation matched with the data processing instruction on the cache and the database in turn according to the processing order, so that the cache data and the database data are consistent. Through the technical scheme of the embodiments of the present application, the purpose of ensuring that the cache data and the database data are consistent is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of big data, and particularly relate to a data processing method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the development of computer and communication technology, human beings have entered the era of big data. The storage and transmission of data under a big data platform are quite different from those of a traditional platform. A big data platform applied in the fields of data query and retrieval has a high requirement for obtaining target data in a timely manner. Therefore, how to quickly obtain target data from massive data is a challenge for a big data platform. In order to solve the above problem, the construction of a big data platform storage system is divided into two parts at present, one is a database component, which is mainly used to store original data, and the other is a cache component, which is mainly used to store query results, wherein the query results are data copies in the database component.

[0003] In a big data platform with a cache component, the transmission mode of data is as follows: when a data request is sent from a front end, the system first queries the cache, if the cache stores target data matching the data request, the target data is directly read from the cache and returned to the front end. If the cache does not store target data matching the data request, the system queries the database, obtains target data matching the data request from the database, returns the target data to the front end, and writes the target data into the cache, so as to improve the speed of obtaining the target data next time. The above mode of obtaining target data is called a penetration cache mode, that is, when an application reads target data, if the target data is not read in the cache, the application continues to read in the database. Correspondingly, a non-penetration cache mode means that when an application reads target data, if the target data is not read in the cache, the application directly returns a reading failure result and does not continue to read in the database.

[0004] The cache and the database are deployed in different environments as different services, when the original data in the database changes, due to unstable network, hardware error or application exception, etc., the data inconsistency problem between the cache and the database is caused, which seriously affects the correctness of various functions of the system. Especially for a fund transaction system, the cache data is usually not allowed to be inconsistent with the database data more than a second. SUMMARY

[0005] Embodiments of the present application provide a data processing method and device, electronic equipment and storage medium, which achieve the purpose of ensuring the consistency of cache data and database data.

[0006] In a first aspect, the embodiments of the present application provide a data processing method, which comprises:

[0007] determining a processing order of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received;

[0008] performing processing operations matched with the data processing instruction on the cache and the database according to the processing order in sequence, so as to keep the cache data consistent with the database data.

[0009] In a second aspect, an embodiment of the present application further provides a data processing apparatus, which comprises:

[0010] a determining module configured to determine a processing order of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received;

[0011] a processing module configured to perform processing operations matched with the data processing instruction on the cache and the database according to the processing order in sequence, so as to keep the cache data consistent with the database data.

[0012] In a third aspect, an embodiment of the present application further provides an electronic device, which comprises:

[0013] one or more processors;

[0014] a storage device configured to store one or more programs,

[0015] when the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method according to any one of the embodiments of the present application.

[0016] In a fourth aspect, an embodiment of the present application further provides a storage medium containing computer executable instructions, which are used to execute the data processing method according to any one of the embodiments of the present application when executed by a computer processor.

[0017] The technical scheme of the embodiments of the present application realizes the purpose of keeping the cache data consistent with the database data by determining a processing order of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received; performing processing operations matched with the data processing instruction on the cache and the database according to the processing order in sequence, so as to keep the cache data consistent with the database data. BRIEF DESCRIPTION OF DRAWINGS

[0018] The above and other features and advantages of the embodiments of the present application will be more apparent from the following detailed description taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals refer to the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.

[0019] Figure 1 A flowchart of a data processing method provided by Embodiment One of the present application;

[0020] Figure 2 A flowchart of a data reading process in a transparent cache mode provided by Embodiment One of the present application;

[0021] Figure 3 A flowchart of a data reading process in a non-transparent cache mode provided by Embodiment One of the present application;

[0022] Figure 4 A flowchart of a data writing process in a transparent cache mode provided by Embodiment One of the present application;

[0023] Figure 5 A flowchart of a data processing method provided by Embodiment Two of the present application;

[0024] Figure 6 A flowchart of a data updating process in a transparent cache mode provided by Embodiment Two of the present application;

[0025] Figure 7 A flowchart of a data processing method provided by Embodiment Three of the present application;

[0026] Figure 8 A flowchart of a data deleting process in a transparent cache mode provided by Embodiment Three of the present application;

[0027] Figure 9 A flowchart of a data processing method provided by Embodiment Four of the present application;

[0028] Figure 10 A flowchart of a data writing process in a non-transparent cache mode provided by Embodiment Four of the present application;

[0029] Figure 11 A flowchart of a data processing method provided by Embodiment Five of the present application;

[0030] Figure 12 A flowchart of a data updating process in a non-transparent cache mode provided by Embodiment Five of the present application;

[0031] Figure 13 A flowchart of a data processing method provided by Embodiment Six of the present application;

[0032] Figure 14 A flowchart of a data deleting process in a non-transparent cache mode provided by Embodiment Six of the present application;

[0033] Figure 15A structural schematic diagram of a data processing device provided by the embodiment seven of the present application is shown in Fig. 7.

[0034] Figure 16 A structural schematic diagram of an electronic device provided by the embodiment eight of the present application is shown in Fig. 8. DETAILED DESCRIPTION

[0035] Embodiments of the present application will be described in more detail by referring to the attached drawings. Although certain embodiments of the present application are shown in the drawings, it is understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather these embodiments are provided for more thorough and complete understanding of the present application. It is understood that the drawings and embodiments of the present application are for illustrative purposes only and are not intended to limit the scope of the present application.

[0036] It is understood that each of the steps recited in the method embodiments of the present application can be performed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit performing the steps shown. The scope of the present application is not limited in this respect.

[0037] The term "comprising" and variations thereof as used herein are used inclusively, i.e., "comprising but not limited to." The term "based on" is "based at least in part on." The term "one embodiment" means "at least one embodiment." The term "another embodiment" means "at least one additional embodiment." The term "some embodiments" means "at least some embodiments." Related definitions are given below in the detailed description.

[0038] It should be noted that the terms "first", "second", and the like in the present application are used only to distinguish different devices, modules or units, and do not imply the order or interdependence of the functions performed by these devices, modules or units.

[0039] It should be noted that the terms "one", "multiple" in the present application are illustrative and not restrictive, and those skilled in the art should understand that unless otherwise explicitly stated in the context, it should be understood as "one or more".

[0040] Embodiment one

[0041] Figure 1 A flowchart of a data processing method provided by the embodiment one of the present application is shown in Fig. 1. The method is designed to ensure that the database data and the cache data are consistent when the data is added, deleted, modified and searched. The method can be performed by a data processing device, which can be implemented in the form of software and / or hardware.

[0042] As Figure 1As shown, the data processing method provided by the embodiment includes the following steps:

[0043] In step 110, when receiving the data processing instruction, the processing order of the cache and the database is determined according to the data processing instruction and the cache mode.

[0044] The data processing instruction includes at least one of the following: data write instruction, data update instruction and data deletion instruction.

[0045] For example, the cache mode includes a transparent cache mode and a non-transparent cache mode. In the transparent cache mode, if the target data is not read from the cache, the target data is continuously read from the database through the cache. For details, please refer to Figure 2 As shown in the data reading flowchart in the transparent cache mode, when the application calls the data loading interface to read data from the cache, it is determined whether the target data is read from the cache. If the target data is read from the cache, the target data is directly returned. If the target data is not read from the cache, the target data is continuously read from the database. Specifically, the target data is queried from the database by calling the database query interface and read. It should be noted that at this time, the database query interface usually needs to be synchronously locked to avoid a large number of query requests penetrating at the moment when the target data is not read from the cache, that is, simultaneously calling the database query interface, resulting in an instantaneous increase in the pressure of the database or even paralysis. When the target data is read from the database, the read target data is written into the cache, and the corresponding result is fed back. In the transparent cache mode, the TTL (Time To Live, survival time) of the cache data usually needs to be set to avoid non-hot data long-term residing in the cache and occupying cache space. The transparent cache mode is suitable for scenarios with high consistency requirements, limited cache capacity, but with some performance sacrifice (due to more performance loss when reading data from the database in the transparent cache mode).

[0046] In the non-transparent cache mode, if the target data is not read from the cache, the result of reading failure is returned, and the target data is no longer continuously read from the database. For details, please refer to Figure 3 As shown in the data reading flowchart in the non-transparent cache mode, when the application calls the data loading interface to read data from the cache, if the target data is not read from the cache, the result information of reading failure is fed back, and the target data is no longer continuously read from the data. The non-transparent cache mode is suitable for scenarios requiring extreme performance, such as all hot data, sufficient cache capacity (full data cache), and no real-time consistency requirement.

[0047] Different data processing instructions correspond to different data processing manners in different cache modes, mainly different processing sequences of cache data and database data, and the processing sequences are used to ensure data consistency.

[0048] In step 120, the cache and the database are sequentially processed according to the processing sequence and the data processing instruction, so that the cache data and the database data are consistent.

[0049] Specifically, when the data processing instruction is received, the processing sequence of the cache and the database is determined according to the data processing instruction and the cache mode, including:

[0050] When the cache mode is the pass-through cache mode, and the data processing instruction is the data write instruction, the processing sequence of the cache and the database is determined as follows: first, the database is executed to perform the data write operation, and then the cache is executed to perform the data write operation.

[0051] Correspondingly, according to the processing sequence, the cache and the database are sequentially processed according to the processing sequence and the data processing instruction, including:

[0052] The data write interface is called to write the target data to the database first;

[0053] If the target data is successfully written to the database, the target data is written to the cache again (wherein the target data can be written to the cache in an asynchronous manner to improve the processing speed), and if the target data fails to be written to the cache, a result information of the write failure is returned, so that when the application reads the target data, the target data is directly read from the database according to the result information, and the operation of writing the target data to the cache is performed again. Correspondingly, refer to Figure 4 As shown in a data write flow diagram in a pass-through cache mode, when the application writes data, the data write interface is called to write the target data to the database first, and if the write fails, the result information of the failure is directly returned; if the write succeeds, the target data is continuously written to the cache, and the target data is usually continuously written to the cache in an asynchronous manner to improve the processing speed.

[0054] Based on the success of the database write, if the target data fails to be written to the cache, in the pass-through cache mode, the application can penetrate the cache to read the target data from the database and write the target data to the cache again, so it will not affect the data consistency.

[0055] The technical scheme of the embodiment, by when receiving the data processing instruction, determining the processing order of the cache and the database according to the data processing instruction and the cache mode; according to the processing order, sequentially performing the processing operation matched with the data processing instruction on the cache and the database, so that the cache data and the database data are consistent. Specifically, when writing data in the penetration cache mode, the target data is preferentially written to the database, and if the target data is successfully written to the database, the target data is written to the cache, so that the correctness of the application reading the target data is ensured, that is, the data consistency is ensured.

[0056] Embodiment two

[0057] Figure 5 A data processing method flow diagram provided by the second embodiment of the application, based on the above-mentioned embodiment technical scheme, the data processing method provided by the embodiment can be applied to the scene of how to ensure data consistency when updating data in the penetration cache mode. The method can be executed by a data processing device, which can be realized in the form of software and / or hardware. Among them, the same or similar explanation as the above-mentioned embodiment will not be repeated, and the corresponding content in the above-mentioned embodiment can be referred to.

[0058] As Figure 5 shown, the data processing method provided by the embodiment includes the following steps:

[0059] Step 510, when the cache mode is the penetration cache mode, and the data processing instruction is the data update instruction, the processing order of the cache and the database is determined as first performing the data processing operation on the cache, and then performing the data processing operation on the database.

[0060] Step 520, by calling the data update service, the old data corresponding to the target data in the cache is preferentially deleted.

[0061] Step 530, if the old data corresponding to the target data in the cache is successfully deleted, the old data corresponding to the target data in the database is updated.

[0062] When data is updated, the technical solution of the embodiment is not realized by updating the cache, but the old data to be updated in the cache is deleted first, and the consistency of the cache data and the database data is better ensured by preferentially deleting the old data. If the cache data is not updated by preferentially deleting the old data in the cache, but is directly updated, if the cache data is successfully updated, the database data may fail to be updated, or the database data is successfully updated, and the cache data may fail to be updated, which will cause inconsistency between the cache data and the database data. Therefore, by preferentially deleting the old data in the cache (but the new data is not written into the cache at this time), then updating the database data, if the database data is successfully updated, the new data is written into the cache in an asynchronous manner, the purpose of updating the cache data is achieved, and the purpose of ensuring the performance is achieved without causing data inconsistency.

[0063] Correspondingly, reference can be made to the flowchart of the data updating process in the penetration cache mode shown in FIG. 2. Figure 6 The application calls the data updating service, and the old data to be updated in the cache is deleted first. If the deletion fails, a failure result information is directly returned, and subsequent operations are not continued. If the old data to be updated in the cache is successfully deleted, the corresponding data in the database is updated. If the database data fails to be updated, a failure result information is returned. If the database data is successfully updated, the corresponding updated record is written into the cache in an asynchronous manner, and the final update of the cache is realized.

[0064] The technical solution of the embodiment is not realized by updating the cache when data is updated in the penetration cache mode, but the old data to be updated in the cache is deleted first, and the consistency of the cache data and the database data is better ensured by preferentially deleting the old data.

[0065] Embodiment Three

[0066] Figure 7 A flowchart of a data processing method provided by the third embodiment of the application is shown in FIG. 3. On the basis of the above-mentioned embodiments, the data processing method provided by the embodiment can be applied to the scene of how to ensure data consistency when data is deleted in the penetration cache mode. The method can be executed by a data processing device, and the device can be realized in the form of software and / or hardware. The same or similar explanations as in the above-mentioned embodiments are not repeated in the embodiment, and reference can be made to the corresponding content in the above-mentioned embodiments.

[0067] As shown in FIG. 3, the data processing method provided by the embodiment includes the following steps: Figure 7

[0068] ​Step 710, when the cache mode is the penetration cache mode, and the data processing instruction is the data deletion instruction, it is determined that the processing sequence of the cache and the database is to perform the data deletion operation on the cache first, and then perform the data deletion operation on the database.

[0069] Step 720, the target data in the cache is deleted preferentially by calling a data deletion service.

[0070] Step 730, if the target data in the cache is deleted successfully, the target data in the database is deleted again, if the target data in the database is deleted unsuccessfully, a result notification of deletion failure is returned, so that the target data is read from the database according to the result notification when the application reads the target data.

[0071] When the target data is deleted, the target data in the cache is deleted first, if the target data in the cache is deleted successfully, the target data in the database is deleted, and finally the result of deletion is the result of deletion of the database, so if the target data in the cache is deleted successfully, and the target data in the database is deleted unsuccessfully, the result information of deletion failure is returned, and data inconsistency is not caused, because the application reads the target data from the database by penetrating the cache when reading the target data, so the target data that is not deleted can be read again.

[0072] Correspondingly, referring to Figure 8 Fig. 7 shows a flow diagram of data deletion in the penetration cache mode, the application calls a data deletion service to delete the target data in the cache, if the deletion is successful, a service for deleting the database is called to delete the target data in the database, and result information of whether the target data in the database is deleted successfully is returned.

[0073] The technical scheme of the embodiment of the application deletes the target data in the cache first when the target data is deleted, if the target data in the cache is deleted successfully, the target data in the database is deleted, and finally the result of deletion is the result of deletion of the database, so if the target data in the cache is deleted successfully, and the target data in the database is deleted unsuccessfully, the result information of deletion failure is returned, and data inconsistency is not caused, because the application reads the target data from the database by penetrating the cache when reading the target data, so the target data that is not deleted can be read again, and the purpose of ensuring consistency of the cache data and the database data is achieved.

[0074] Embodiment four

[0075] Figure 9A flowchart of a data processing method provided in Embodiment Four of the present application is shown. Based on the above-mentioned embodiments, the data processing method provided in this embodiment can be applied to the scenario of how to ensure data consistency when writing data in a non-penetrating cache mode. The method can be executed by a data processing device, which can be implemented in the form of software and / or hardware. The same or similar explanations as in the above-mentioned embodiments are not repeated in this embodiment, and the corresponding content in the above-mentioned embodiments can be referred to.

[0076] As shown in Figure 9 The data processing method provided in this embodiment includes the following steps:

[0077] In step 910, when the cache mode is a non-penetrating cache mode and the data processing instruction is a data write instruction, it is determined that the processing sequence of the cache and the database is to perform data write operation on the database first and then perform data write operation on the cache.

[0078] In step 920, the target data is written to the database by calling a data write interface.

[0079] In step 930, if the target data is successfully written to the database, the target data is further written to the cache. If the target data fails to be written to the cache, the result information of the cache write failure is written to the exception record table in the database.

[0080] In step 940, the exception record is read from the exception record table in the database by an exception record compensation timing task, and the type of the exception record is judged. If the exception record is the result information of the cache write failure, the operation of writing the target data to the cache is performed. If the target data is successfully written to the cache, the exception record is deleted from the exception record table.

[0081] Specifically, if the data write interface is called again, in order to ensure the idempotency of the processing (i.e., the results of one request or multiple requests for the same operation are consistent, and different results will not be generated due to multiple clicks), it is first determined whether there is result information of cache write failure in the exception record table. If not, it is further checked whether the target data exists in the business table of the database. If the target data does not exist in the business table, the operation of writing the target data to the database is performed. If the target data exists in the business table, the operation of writing the target data to the cache is performed.

[0082] The exception record is read from the exception record table in the database by an exception record compensation timing task, and the corresponding operation is performed according to the type of the exception record, so that when the target data is successfully written to the database but fails to be written to the cache, the target data is finally successfully written to the cache, and the purpose of data consistency is achieved.

[0083] Correspondingly, referring to Figure 10 Fig. 1 shows a flowchart of a data writing process in a non-penetration cache mode. An application invokes a data writing interface to write target data to a database. If the target data is successfully written to the database, the target data is written to the cache. If the target data fails to be written to the database, a failure result is returned. If the target data fails to be written to the cache, a result information of the cache writing failure is written to an exception record table in the database. An exception record compensation timing task is executed once to write the target data to the cache. Before the target data is successfully written to the cache, in the non-penetration cache mode, only the target data is read from the cache. Even if the target data cannot be read from the cache, the database is not continuously read. Therefore, the data inconsistency problem does not occur. If the target data is successfully written to the cache, a success result is returned.

[0084] The technical solution of the embodiment writes the target data to the database first when writing data in the non-penetration cache mode. If the target data is successfully written to the database, the target data is written to the cache. If the target data fails to be written to the cache, a result information of the cache writing failure is written to an exception record table in the database. An exception record compensation timing task reads the exception record from the exception record table in the database. If the exception record is the result information of the cache writing failure, an operation of writing the target data to the cache is continuously executed. If the target data is successfully written to the cache, the exception record is deleted from the exception record table. The consistency of the database data and the cache data is achieved.

[0085] Embodiment Five

[0086] Figure 11 Fig. 1 shows a flowchart of a data processing method provided by the embodiment five. On the basis of the above-mentioned embodiments, the data processing method provided by the embodiment five is applicable to a scenario of how to ensure data consistency when updating data in a non-penetration cache mode. The method can be executed by a data processing device. The device can be implemented in the form of software and / or hardware. The same or similar explanations as those in the above-mentioned embodiments are not described herein again, and the corresponding content in the above-mentioned embodiments can be referred to.

[0087] As Figure 11 shown, the data processing method provided by the embodiment includes the following steps.

[0088] In step 1110, when the cache mode is a non-penetration cache mode and the data processing instruction is a data update instruction, it is determined that the processing sequence of the cache and the database is to perform a data update operation on the database first, and then perform a data update operation on the cache.

[0089] Step 1120, first update the database by calling the data update service, if the database data update is successful, then continue to update the cache, if the cache data update fails, write the cache update failure result information to the exception record table of the database.

[0090] Step 1130, read the exception record from the exception record table of the database by the exception record compensation timing task, and judge the type of the exception record, if the exception record is the cache update failure result information, then judge which one is updated, the storage time of the cache data or the storage time of the database data, if the storage time of the database data is updated, then update the cache data with the database data, if the update is successful, then delete the exception record from the exception record table; if the storage time of the cache data is updated, then delete the exception record from the exception record table.

[0091] Specifically, if the data deletion service is called again, in order to ensure the idempotency of the processing (that is, the result of one request or multiple requests for the same operation is consistent, and different results will not be produced because of multiple clicks), first judge whether there is cache deletion failure result information in the exception record table, if not, then continue to execute the operation of first deleting the database data by calling the data deletion service.

[0092] Correspondingly, refer to Figure 12As shown in a flow diagram of a data update process in a non-penetrating cache mode, an application calls a data update service, the data update service first calls an interface of a database update operation, if the database data update fails, a failure result is returned; if the database data update succeeds, cache data is updated, if the cache data update succeeds, a success result is returned, if the cache data update fails, the cache data update failure result information is written into an exception record table of the database, if the exception record table writing succeeds, a success result is returned, if the writing fails, a failure result is returned. If the application calls the data update service again, the idempotency of the processing needs to be ensured, it is first judged whether the exception record table exists the cache data update failure result information, if not, the database data update operation is executed, if the database data update succeeds, the cache data is updated, if the cache data update succeeds, a success result is returned, otherwise, the operation of writing the cache data update failure result information into the exception record table of the database is continued. The exception record compensation timing task reads the exception record from the exception record table of the database, if the exception record is the cache update failure result information, it is judged which one of the cache data storage time and the database data storage time is updated, if the database data storage time is updated, the cache data is updated by using the database data, if the update succeeds, the exception record is deleted from the exception record table; if the cache data storage time is updated, the exception record is deleted from the exception record table.

[0093] The technical scheme of the embodiment, in the non-penetrating cache mode, when updating data, the database data is updated first, if the database data update succeeds, the cache is continued to be updated, if the cache data update fails, the cache update failure result information is written into the exception record table of the database, the exception record compensation timing task reads the exception record from the exception record table of the database, and the data update operation is continued until the cache data update succeeds, the consistency of the database data and the cache data is achieved.

[0094] Embodiment six

[0095] Figure 13 A flow diagram of a data processing method provided by the embodiment six of the application. On the basis of the above-mentioned embodiments, the data processing method provided by the embodiment can be applied to the scenario of how to ensure data consistency when deleting data in the non-penetrating cache mode. The method can be executed by a data processing device, which can be realized in the form of software and / or hardware. The same or similar explanations as the above-mentioned embodiments are not repeated in this embodiment, and the corresponding contents in the above-mentioned embodiments can be referred to.

[0096] As Figure 13 shown, the data processing method provided by the embodiment includes the following steps:

[0097] Step 1310, when the cache mode is a non-penetrating cache mode, and the data processing instruction is a data deletion instruction, it is determined that the processing order of the cache and the database is to perform the data deletion operation on the database first, and then perform the data deletion operation on the cache.

[0098] Step 1320, the data deletion operation is performed on the database by calling the data deletion service, if the database data deletion is successful, the data deletion operation is continued on the cache, if the cache data deletion fails, the cache deletion failure result information is written into the exception record table of the database.

[0099] Step 1330, the exception record is read from the exception record table of the database by an exception record compensation timing task, and the type of the exception record is judged, if the exception record is the cache deletion failure result information, the cache data deletion operation is continued, if the cache data deletion is successful, the exception record is deleted from the exception record table.

[0100] If the data deletion service is called again, the idempotency of the processing needs to be ensured, first, it is judged whether there is cache deletion failure result information in the exception record table, if not, the operation of performing the data deletion on the database by calling the data deletion service is continued, if the database data deletion is successful, the cache data deletion is continued, if the cache data deletion is successful, the success result is returned, if the cache data deletion fails, the operation of writing the cache deletion failure result information into the exception record table of the database is continued.

[0101] Correspondingly, referring to Figure 14 the non-penetrating cache mode, the application calls the data deletion service, the data deletion service first calls the database record deletion interface, if the database record deletion fails, the failure result is returned, if the database record deletion is successful, the cache data deletion operation is continued, if the cache data deletion is successful, the success result is returned, if the cache data deletion fails, the cache data deletion failure result information is written into the exception record table, if the exception record table writing is successful, the success result is returned, otherwise the failure result is returned. If the application calls the data deletion service again, the idempotency of the processing needs to be ensured, first, it is judged whether there is cache data deletion failure exception record in the exception record table, if not, the database record deletion operation is executed, if the deletion is successful, the cache data deletion operation is continued.

[0102] The technical scheme of the embodiment, in the non-penetration cache mode, when deleting data, first performs a data deletion operation on the database, if the database data deletion is successful, continues to perform a data deletion operation on the cache, if the cache data deletion fails, writes the cache deletion failure result information into the exception record table of the database, reads the exception record from the exception record table of the database through the exception record compensation timing task, and continues to perform the data deletion operation until the cache data deletion is successful, achieving the consistency of the database data and the cache data.

[0103] In the non-penetration cache mode, in addition to all the business fields, the exception record table needs to increase the following fields as shown in Table 1:

[0104] Table 1: New field table

[0105]

[0106] The operate_type operation type indicates that different operations need to perform different compensation processes.

[0107] The operate_time is used as a comparison time in the updated compensation process.

[0108] In addition, a time field needs to be added in the cache to record the time of data update and addition.

[0109] Embodiment seven

[0110] Figure 15 A data processing apparatus is provided for the seventh embodiment of the application, which comprises a determination module 1510 and a processing module 1520.

[0111] The data processing instruction comprises at least one of the following: a data write instruction, a data update instruction, and a data deletion instruction.

[0112] The cache mode comprises a penetration cache mode and a non-penetration cache mode.

[0113] In the penetration cache mode, if the target data is not read from the cache, the target data is continued to be read from the database through the cache.

[0114] In the non-penetration cache mode, if the target data is not read from the cache, a read failure result is returned, and the target data is no longer read from the database.

[0115] On the basis of each of the above technical solutions, the determining module 1510 comprises: a first determining unit, configured to, when the cache mode is the penetration cache mode and the data processing instruction is a data write instruction, determine the processing sequence of the cache and the database as performing the data write operation on the database first and then performing the data write operation on the cache.

[0116] On the basis of each of the above technical solutions, the processing module 1520 comprises: a first processing unit, configured to write the target data to the database first by calling a data write interface;

[0117] If the target data is successfully written to the database, the target data is written to the cache again, and if the target data fails to be written to the cache, a result information of the write failure is returned, so that the target data is read from the database directly when the application reads the target data, and the operation of writing the target data to the cache is performed again.

[0118] On the basis of each of the above technical solutions, the determining module 1510 comprises: a second determining unit, configured to, when the cache mode is the penetration cache mode and the data processing instruction is a data update instruction, determine the processing sequence of the cache and the database as performing the data processing operation on the cache first and then performing the data processing operation on the database.

[0119] On the basis of each of the above technical solutions, the processing module 1520 comprises: a second processing unit, configured to preferentially delete old data corresponding to the target data in the cache by calling a data update service;

[0120] If the old data corresponding to the target data in the cache is successfully deleted, the old data corresponding to the target data in the database is updated again;

[0121] If the old data corresponding to the target data in the database is successfully updated, the new data corresponding to the target data after the update is written to the cache in an asynchronous mode.

[0122] On the basis of each of the above technical solutions, the determining module 1510 comprises: a third determining unit, configured to, when the cache mode is the penetration cache mode and the data processing instruction is a data deletion instruction, determine the processing sequence of the cache and the database as performing the data deletion operation on the cache first and then performing the data deletion operation on the database.

[0123] On the basis of each of the above technical solutions, the processing module 1520 comprises: a third processing unit, configured to preferentially delete the target data in the cache by calling a data deletion service;

[0124] If the target data in the cache is successfully deleted, the target data in the database is also deleted, and if the target data in the database is unsuccessfully deleted, a result notification of the deletion failure is returned, so that the target data is continuously read from the database according to the result notification when the target data is read by the application.

[0125] On the basis of the above technical solutions, the determining module 1510 comprises a fourth determining unit configured to, when the cache mode is the non-penetration cache mode and the data processing instruction is a data write instruction, determine the processing sequence of the cache and the database as performing the data write operation on the database first and then performing the data write operation on the cache.

[0126] On the basis of the above technical solutions, the processing module 1520 comprises a fourth processing unit configured to write the target data to the database by calling a data write interface first.

[0127] If the target data is successfully written to the database, the target data is written to the cache again, and if the target data is unsuccessfully written to the cache, result information of the cache write failure is written to an exception record table in the database.

[0128] If the data write interface is called again, it is first determined whether the result information of the cache write failure exists in the exception record table, if not, it is further determined whether the target data exists in a business table of the database, if the target data does not exist in the business table, the operation of writing the target data to the database is performed, and if the target data exists in the business table, the operation of writing the target data to the cache is performed.

[0129] The exception record compensation timing task reads the exception record from the exception record table of the database and determines the type of the exception record, if the exception record is the result information of the cache write failure, the operation of writing the target data to the cache is performed, and if the target data is successfully written to the cache, the exception record is deleted from the exception record table.

[0130] On the basis of the above technical solutions, the determining module 1510 comprises a fifth determining unit configured to, when the cache mode is the non-penetration cache mode and the data processing instruction is a data update instruction, determine the processing sequence of the cache and the database as performing the data update operation on the database first and then performing the data update operation on the cache.

[0131] On the basis of the above technical solutions, the processing module 1520 comprises a fifth processing unit configured to perform data update on the database by calling a data update service, if the data update on the database is successful, continue to perform data update on the cache, and if the data update on the cache fails, write result information of the cache update failure to an exception record table of the database.

[0132] If the data update service is called again, it is first determined whether the result information of the cache update failure exists in the exception record table, and if not, the operation of first updating the database through the data update service is continued.

[0133] The exception record compensation timing task reads the exception record from the exception record table of the database, and determines the type of the exception record. If the exception record is the result information of the cache update failure, it is determined which of the storage time of the cache data and the storage time of the database data is updated. If the storage time of the database data is updated, the cache data is updated using the database data. If the update is successful, the exception record is deleted from the exception record table. If the storage time of the cache data is updated, the exception record is deleted from the exception record table.

[0134] On the basis of the above technical solutions, the determining module 1510 comprises a sixth determining unit configured to, when the cache mode is the non-penetration cache mode and the data processing instruction is a data deletion instruction, determine the processing order of the cache and the database as first performing the data deletion operation on the database and then performing the data deletion operation on the cache.

[0135] On the basis of the above technical solutions, the processing module 1520 comprises a sixth processing unit configured to first perform the data deletion operation on the database through the data deletion service. If the database data deletion is successful, the data deletion operation on the cache is continued. If the cache data deletion fails, the result information of the cache deletion failure is written into the exception record table of the database.

[0136] If the data deletion service is called again, it is first determined whether the result information of the cache deletion failure exists in the exception record table, and if not, the operation of first performing the data deletion on the database through the data deletion service is continued.

[0137] The exception record compensation timing task reads the exception record from the exception record table of the database, and determines the type of the exception record. If the exception record is the result information of the cache deletion failure, the cache data deletion operation is continued. If the cache data deletion is successful, the exception record is deleted from the exception record table.

[0138] The technical solutions of the embodiment achieve the purpose of ensuring the consistency of the cache data and the database data by, when receiving a data processing instruction, determining the processing order of the cache and the database according to the data processing instruction and the cache mode, and sequentially performing the processing operation matched with the data processing instruction on the cache and the database according to the processing order, so that the cache data and the database data are kept consistent.

[0139] The data processing apparatus provided by the embodiments of the present application can execute the data processing method provided by any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of executing the method.

[0140] It is worth noting that each unit and module included in the above apparatus is only divided according to the function logic, but is not limited to the above division, as long as the corresponding function can be realized; in addition, the specific name of each functional unit is only for the convenience of mutual differentiation, and does not serve to limit the protection scope of the embodiments of the present application.

[0141] Embodiment eight

[0142] Reference will now be made to the following description Figure 16 , which shows a structural schematic diagram of an electronic device (for example, a terminal device or a server in Figure 16 ) suitable for use to implement the embodiments of the present application. The terminal device in the embodiments of the present application can include, but is not limited to, a fixed terminal such as a notebook computer, a desktop computer, and the like. Figure 16 The electronic device shown is merely an example, and should not bring any limitation to the function and use range of the embodiments of the present application.

[0143] As shown in Figure 16 , the electronic device 400 can include a processing apparatus (for example, a central processing unit, a graphics processing unit, and the like) 401, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 402 or programs loaded from a storage apparatus 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing apparatus 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0144] Generally, the following apparatuses can be connected to the I / O interface 405: an input apparatus 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, and the like; an output apparatus 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; a storage apparatus 408 including, for example, a magnetic tape, a hard disk, and the like; and a communication apparatus 409. The communication apparatus 409 can allow the electronic device 400 to perform wireless or wired communication with other devices to exchange data. Although Figure 16 The electronic device 400 having various apparatuses is shown, but it is understood that it is not required to implement or have all the apparatuses shown. More or fewer apparatuses can be alternatively implemented or had.

[0145] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program in accordance with embodiments of the present application. For example, embodiments of the present application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for carrying out the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from the network by the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the methods of the embodiments of the present application are performed.

[0146] The terminal provided by the embodiments of the present application belongs to the same inventive concept as the data processing method provided by the above-described embodiments, and the technical details not described in detail in the embodiments of the present application can be referred to the above-described embodiments, and the embodiments of the present application have the same beneficial effects as the above-described embodiments.

[0147] Embodiment Nine

[0148] The ninth embodiment of the present application provides a computer storage medium, which stores a computer program, and the program is executed by a processor to implement the data processing method provided by the above-described embodiments.

[0149] It should be noted that the computer readable medium in the present application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable storage medium may, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, 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 above. In the present application, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present application, the computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer readable signal medium can also be any computer readable medium other than the computer readable storage medium that can send, propagate or transmit the program for use by or in connection with an instruction execution system, device or apparatus. The program code contained in the computer readable medium can be transmitted by any suitable medium, including but not limited to a wire, an optical fiber, an RF (radio frequency) or the like, or any suitable combination of the above.

[0150] In some embodiments, the client, server, or both can communicate using any current known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.

[0151] The computer readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device and not be assembled into the electronic device.

[0152] The computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, the electronic device:

[0153] When receiving the data processing instruction, a processing sequence of the cache and the database is determined according to the data processing instruction and the cache mode;

[0154] According to the processing sequence, a processing operation matched with the data processing instruction is performed on the cache and the database in sequence, so that the cache data and the database data are kept consistent.

[0155] Computer program code for carrying out operations of the present application can 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 and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can 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 server. In the latter scenario, the remote computer can 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 can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0156] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may

[0157] The units described in the embodiments of the present application can be implemented by software, or by hardware, or by a combination of software and hardware. In some cases, the names of the units do not constitute a limitation on the units themselves, for example, the editable content display unit can also be described as an "editing unit".

[0158] The functionality described above can be performed, at least in part, by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Application-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.

[0159] In the context of the present application, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more of: 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.

[0160] The foregoing description merely exemplifies the preferred embodiments of the present application and the principles of the technology involved. It is understood by those skilled in the art that the disclosed scope of the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and also covers other technical solutions formed by any combinations of the above technical features or their equivalent features without departing from the disclosed concept. For example, the technical solutions formed by the mutual replacement of the above features and the technical features disclosed in the present application (but not limited to) having similar functions.

[0161] Further, although operations are depicted in a particular, chronological sequence, this should not be understood as requiring such order unless specifically specified. In some environments, multitasking and parallel processing can be advantageous. Likewise, the specific sequence of operations illustrated in the above discussion can not be required, unless specifically indicated otherwise. Some features described in the context of separate embodiments can also be implemented together in a single embodiment. Conversely, various features described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable sub-combination.

[0162] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims

1. A data processing method, characterized by, The method comprises the steps of: determining the processing sequence of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received, wherein the cache mode comprises a transparent cache mode and a non-transparent cache mode; performing processing operations matched with the data processing instruction on the cache and the database in sequence according to the processing sequence, so that the cache data and the database data are consistent; wherein the step of determining the processing sequence of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received comprises: when the cache mode is the transparent cache mode and the data processing instruction is a data write instruction, determining the processing sequence of the cache and the database as performing the data write operation on the database first and then performing the data write operation on the cache; wherein the step of performing processing operations matched with the data processing instruction on the cache and the database in sequence according to the processing sequence, so that the cache data and the database data are consistent, comprises: writing target data to the database through a data write interface; if the target data is successfully written to the database, then writing the target data to the cache, and if the target data fails to be written to the cache, returning a result information of the write failure, so that the target data is directly read from the database when the target data is read by an application, and the operation of writing the target data to the cache is performed again; wherein the step of determining the processing sequence of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received comprises: when the cache mode is the non-transparent cache mode and the data processing instruction is a data write instruction, determining the processing sequence of the cache and the database as performing the data write operation on the database first and then performing the data write operation on the cache; wherein the step of performing processing operations matched with the data processing instruction on the cache and the database in sequence according to the processing sequence, so that the cache data and the database data are consistent, comprises: writing target data to the database through a data write interface; if the target data is successfully written to the database, then writing the target data to the cache, and if the target data fails to be written to the cache, writing a result information of the cache write failure to an exception record table in the database; if the data write interface is called again, then determining whether the result information of the cache write failure exists in the exception record table, if not, then verifying whether the target data exists in a business table of the database, if the target data does not exist in the business table, then performing the operation of writing the target data to the database, and if the target data exists in the business table, then performing the operation of writing the target data to the cache, so that the cache data and the database data are consistent.

2. The method of claim 1, wherein, The data processing instruction comprises at least one of a data write instruction, a data update instruction and a data deletion instruction.

3. The method of claim 1, wherein, The method comprises the steps of: in the transparent cache mode, if the target data is not read from the cache, then the target data is continuously read from the database through the cache; In the non-penetration cache mode, if the target data is not read from the cache, a read failure result is returned, and the target data is no longer read from the database.

4. The method of claim 1, wherein, The determining the processing sequence of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received comprises: When the cache mode is the penetration cache mode and the data processing instruction is a data update instruction, it is determined that the processing sequence of the cache and the database is to perform the data processing operation on the cache first, and then perform the data processing operation on the database.

5. The method of claim 4, wherein, The performing the processing operation matched with the data processing instruction on the cache and the database according to the processing sequence to keep the cache data and the database data consistent comprises: The old data corresponding to the target data in the cache is deleted preferentially by calling a data update service; If the old data corresponding to the target data in the cache is successfully deleted, the old data corresponding to the target data in the database is updated; If the old data corresponding to the target data in the database is successfully updated, the new data corresponding to the target data after the update is written into the cache in an asynchronous mode.

6. The method of claim 1, wherein, The determining the processing sequence of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received comprises: When the cache mode is the penetration cache mode and the data processing instruction is a data deletion instruction, it is determined that the processing sequence of the cache and the database is to perform the data deletion operation on the cache first, and then perform the data deletion operation on the database.

7. The method of claim 6, wherein, The performing the processing operation matched with the data processing instruction on the cache and the database according to the processing sequence to keep the cache data and the database data consistent comprises: The target data in the cache is deleted preferentially by calling a data deletion service; If the target data in the cache is successfully deleted, the target data in the database is deleted, and if the target data in the database is not successfully deleted, a deletion failure result notification is returned, so that the target data is continuously read from the database when the target data is read by an application.

8. The method of claim 1, wherein, The performing the processing operation matched with the data processing instruction on the cache and the database according to the processing sequence to keep the cache data and the database data consistent further comprises: An exception record compensation timing task reads the exception record from an exception record table of the database and judges the type of the exception record, if the exception record is a result information of cache writing failure, an operation of writing the target data into the cache is performed, and if the target data is successfully written into the cache, the exception record is deleted from the exception record table.

9. The method of claim 1, wherein, The determining the processing sequence of the cache and the database according to the data processing instruction and the cache mode when the data processing instruction is received comprises: When the cache mode is the non-penetration cache mode and the data processing instruction is a data update instruction, it is determined that the processing sequence of the cache and the database is to perform the data update operation on the database first, and then perform the data update operation on the cache.

10. The method of claim 9, wherein, The processing operation matched with the data processing instruction is sequentially performed on the cache and the database according to the processing sequence, so that the cache data and the database data are kept consistent, and the processing sequence comprises: The data update service is called to perform data update on the database first, if the database data update is successful, the data update on the cache is continued, if the cache data update fails, the result information of the cache update failure is written into the exception record table of the database; If the data update service is called again, it is firstly judged whether the result information of the cache update failure exists in the exception record table, if not, the operation of calling the data update service to perform data update on the database first is continued.

11. The method of claim 10, wherein, The processing operation matched with the data processing instruction is sequentially performed on the cache and the database according to the processing sequence, so that the cache data and the database data are kept consistent, and the processing sequence comprises: The exception record compensation timing task reads the exception record from the exception record table of the database, and judges the type of the exception record, if the exception record is the result information of the cache update failure, it is judged which one is updated, the storage time of the cache data or the storage time of the database data, if the storage time of the database data is updated, the cache data is updated by using the database data, if the update is successful, the exception record is deleted from the exception record table; if the storage time of the cache data is updated, the exception record is deleted from the exception record table.

12. The method of claim 1, wherein, When the data processing instruction is received, the processing sequence of the cache and the database is determined according to the data processing instruction and the cache mode, and the processing sequence comprises: When the cache mode is the non-penetration cache mode, and the data processing instruction is the data deletion instruction, it is determined that the processing sequence of the cache and the database is that the data deletion operation is performed on the database first, and then the data deletion operation is performed on the cache.

13. The method of claim 12, wherein, The processing operation matched with the data processing instruction is sequentially performed on the cache and the database according to the processing sequence, so that the cache data and the database data are kept consistent, and the processing sequence comprises: The data deletion service is called to perform data deletion on the database first, if the database data deletion is successful, the data deletion on the cache is continued, if the cache data deletion fails, the result information of the cache deletion failure is written into the exception record table of the database; If the data deletion service is called again, it is firstly judged whether the result information of the cache deletion failure exists in the exception record table, if not, the operation of calling the data deletion service to perform data deletion on the database first is continued.

14. The method of claim 13, wherein, The processing operation matched with the data processing instruction is sequentially performed on the cache and the database according to the processing sequence, so that the cache data and the database data are kept consistent, and the processing sequence comprises: The exception record compensation timing task reads the exception record from the exception record table of the database, and judges the type of the exception record, if the exception record is the result information of the cache update failure, it is judged which one is updated, the storage time of the cache data or the storage time of the database data, if the storage time of the database data is updated, the cache data is updated by using the database data, if the update is successful, the exception record is deleted from the exception record table; if the storage time of the cache data is updated, the exception record is deleted from the exception record table.

15. A data processing apparatus, characterized by The processing operation matched with the data processing instruction is sequentially performed on the cache and the database according to the processing sequence, so that the cache data and the database data are kept consistent, and the processing sequence comprises: determining, when a data processing instruction is received, a processing sequence of the cache and the database according to the data processing instruction and a cache mode, wherein the cache mode comprises a pass-through cache mode and a non-pass-through cache mode; processing, according to the processing sequence, the cache and the database in sequence to perform a processing operation matched with the data processing instruction, so as to keep the cache data consistent with the database data; wherein the determining module comprises a first determining unit configured to, when the cache mode is the pass-through cache mode and the data processing instruction is a data write instruction, determine that the processing sequence of the cache and the database is to perform a data write operation on the database first and then perform a data write operation on the cache; wherein the processing module comprises a first processing unit configured to write target data to the database through a data write interface first; if the target data is successfully written to the database, then write the target data to the cache, and if the target data fails to be written to the cache, return a result information of the write failure, so that, when an application reads the target data, the target data is directly read from the database according to the result information, and an operation of writing the target data to the cache is performed again; wherein the determining module comprises a fourth determining unit configured to, when the cache mode is the non-pass-through cache mode and the data processing instruction is the data write instruction, determine that the processing sequence of the cache and the database is to perform a data write operation on the database first and then perform a data write operation on the cache; wherein the processing module comprises a fourth processing unit configured to write target data to the database through a data write interface first; if the target data is successfully written to the database, then write the target data to the cache, and if the target data fails to be written to the cache, write a result information of the cache write failure to an exception record table in the database; if the data write interface is called again, then first determine whether the result information of the cache write failure exists in the exception record table, if not, then check whether the target data exists in a business table of the database, if the target data does not exist in the business table, perform an operation of writing the target data to the database, and if the target data exists in the business table, perform an operation of writing the target data to the cache, so as to keep the cache data consistent with the database data.

16. An electronic device, comprising: The electronic device comprises: one or more processors; a storage device configured to store one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method according to any one of claims 1-14.

17. A storage medium containing computer-executable instructions for performing the data processing method according to any one of claims 1-14 when executed by a computer processor.

Citation Information

Patent Citations

  • Data processing method and device, computing equipment and storage medium

    CN111177161A