Data processing method and device, equipment and storage medium
By introducing interception and execution code generation mechanism based on cache processing components in the data processing method, the problem of lack of systematic caching solutions in the existing technology is solved, and efficient data processing and development efficiency is improved.
Patent Information
- Application Number
- CN202311715724.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2025-06-13
AI Technical Summary
The lack of systematic caching solutions in the prior art leads to high development costs for processing data based on cache, and there are problems such as low data consistency, low space utilization and low hit rate.
Provide a data processing method, by intercepting data processing requests based on the cache processing component, determining the request type and generating execution code, realizing cache-based data processing, reducing the number of accesses to the database, and improving development efficiency and data processing efficiency.
The cache-based data processing is realized, which reduces development costs, improves data processing efficiency and memory requirements, and ensures data consistency and space utilization.
Smart Images

Figure CN120144616A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of data processing, and in particular, to a data processing method, apparatus, device, and storage medium. Background Art
[0002] Online virtual service products are mainly provided for C-end users. The characteristics of C-end user products are relatively simple services, large traffic, and high requirements for response timeliness. Therefore, the service data involved needs to provide highly consistent, high-performance, and highly stable data processing services. Caching can perform data processing such as data writing, data reading, and data deletion on service data.
[0003] In the prior art, when processing service data based on caching, it is necessary to develop corresponding data processing algorithms according to specific service products to process the service data corresponding to the service products.
[0004] In the process of implementing the present invention, the inventors found that there are at least the following technical problems in the prior art:
[0005] The lack of a systematic caching solution leads to a high development cost for processing data based on caching. Summary of the Invention
[0006] The present invention provides a data processing method, apparatus, device, and storage medium to provide an overall systematic caching solution.
[0007] In a first aspect, an embodiment of the present invention provides a data processing method, including:
[0008] Intercepting a received data processing request based on a cache processing component aspect;
[0009] Determining the request type of the data processing request, and determining the execution code corresponding to the data processing request according to the request type;
[0010] Executing the execution code to obtain the request result corresponding to the data processing request.
[0011] In a second aspect, an embodiment of the present invention further provides a data processing apparatus, including:
[0012] An interception module, configured to intercept a received data processing request based on a cache processing component aspect;
[0013] A determination module, configured to determine the request type of the data processing request, and determine the execution code corresponding to the data processing request according to the request type;
[0014] An execution module, configured to execute the execution code to obtain the request result corresponding to the data processing request.
[0015] In a third aspect, an embodiment of the present invention further provides a computer device, which includes:
[0016] One or more processors;
[0017] A storage device for storing one or more programs,
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method described in any one of the first aspects.
[0019] In a fourth aspect, an embodiment of the present invention further provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute the data processing method described in any one of the first aspects when executed by a computer processor.
[0020] The embodiments in the above-mentioned invention have the following advantages or beneficial effects:
[0021] The data processing method provided by the embodiment of the present invention includes: intercepting the received data processing request based on the cache processing component aspect; determining the request type of the data processing request, and determining the execution code corresponding to the data processing request according to the request type; executing the execution code to obtain the request result corresponding to the data processing request. In the above technical solution, first, the data processing request for the database can be intercepted based on the cache processing component aspect, so as to execute the data processing request based on the cache, reduce the number of accesses to the database, and improve the efficiency and memory requirements of data processing. Second, the request type of the data processing request can be determined. After determining the request type of the data processing request, the execution code corresponding to the data processing request can be generated according to the request type of the data processing request and the request annotation of the data processing request of this request type set in advance, realizing the modular generation of the execution code corresponding to data processing, improving the development efficiency of data processing based on the cache, and then the data processing request can be executed based on the cache to obtain the corresponding request result. Compared with the prior art, the request result of the data processing request is determined based on the execution code of the modularly generated data processing request, improving the data processing efficiency. Description of the Drawings
[0022] Figure 1 It is a flowchart of a data processing method provided by an embodiment of the present invention;
[0023] Figure 2 It is a flowchart of another data processing method provided by an embodiment of the present invention;
[0024] Figure 3 It is a schematic structural diagram of a cache processing component in another data processing method provided by an embodiment of the present invention;
[0025] Figure 4 A structural schematic diagram of a data processing device provided by an embodiment of the present invention;
[0026] Figure 5 A structural schematic diagram of a computer device provided by an embodiment of the present invention. Detailed implementation manners
[0027] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. Additionally, it should be noted that for the sake of description, only the parts related to the present invention rather than all the structures are shown in the drawings.
[0028] Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operations are completed, but there can also be additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, and so on. In addition, without conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other.
[0029] When the service product is a health service, different services and different suppliers use different caches for data processing of service data, mainly non-systematic caches. There are various types of cache problems, and problems can only be solved according to the actual situation.
[0030] Cache exception problems include the lack of a systematic cache solution, low development efficiency, low data consistency, low space utilization rate, low hit rate, etc.
[0031] Currently, general caches on the market are rarely used in real scenarios because they need to consider numerous usage scenarios, have complex configurations, and are difficult to maintain. More development teams choose to use their own caches. However, developing a cache requires significant costs and may not fully meet the original design intention, resulting in a lack of a systematic cache solution. The data structure storage solution and code framework solution for the overall cache require a large amount of time and cost. Usually, after the initial design is completed, secondary modifications and iterations are still needed during the later development and usage processes, so the costs will continue to increase, leading to low development efficiency. Health services involve a large number of service status changes. For example, in the "My Rights and Interests" list, all available rights and interests need to be displayed, which may belong to private users, family users, or enterprise users. When a user consults a doctor based on any right or interest in "My Rights and Interests", the status of that right or interest is "under consultation". After the consultation ends, the status of that right or interest is "used up". It is difficult for the cache to update these statuses in a timely manner, resulting in low data consistency. Generally, caches can only be queried through a single dimension. If a new query dimension needs to be added, multiple copies of cache data need to be heterogeneous. For example, if there are two query dimensions for rights and interests data, namely order ID and service package ID, then the order ID-rights and interests data and service package ID-rights and interests data need to be stored separately in the cache as two key-value pairs, resulting in low space utilization. The cache hit rate is positively correlated with the complexity of the cache implementation. The higher the complexity, the higher the probability of subtle bugs. Therefore, usually, the cache solution will weigh the pros and cons and choose a compromise solution with a moderate hit rate. As a result, the load pressure on the database may be relatively large.
[0032] Therefore, this application proposes a data processing method to provide an overall systematic cache solution.
[0033] Next, the data processing method proposed in this application will be described in detail in combination with the diagrams and embodiments.
[0034] Figure 1 It is a flowchart of a data processing method provided by an embodiment of the present invention. The embodiment of the present invention is applicable to situations where systematic data processing needs to be performed based on a cache. This method can be executed by a data processing device, and the device can be implemented in software and / or hardware. As Figure 1 described, the method specifically includes the following steps:
[0035] Step 110: Intercept the received data processing request based on the cache processing component aspect.
[0036] Among them, the cache processing component aspect can be a Spring Aop aspect. Here, the data processing request can be understood as data writing, data reading, data reading and writing, or data deletion for the database.
[0037] Specifically, the cache processing component aspect can intercept data processing requests for the database so that, before or after the data processing requests operate on the database, the data processing requests are executed based on the cache.
[0038] In the embodiment of the present invention, intercepting data processing requests for the database based on the cache processing component aspect facilitates executing data processing requests based on the cache and improves data processing efficiency.
[0039] Step 120: Determine the request type of the data processing request, and determine the execution code corresponding to the data processing request according to the request type.
[0040] Among them, the request type of the data processing request can be data writing, data reading, data reading and writing, or data deletion.
[0041] Specifically, first, it can be determined that the request type of the intercepted data processing request is data writing, data reading, data reading and writing, or data deletion. Second, the execution code corresponding to the data request can be generated according to the request type of the data processing request.
[0042] Specifically, when it is determined that the data processing request is a data reading request, the data processing request can be abstracted as a data query. Specifically, it can be determined that it is: querying a single object according to the primary key & foreign key, or querying multiple objects according to the primary key & foreign key list. Furthermore, the data query code corresponding to the data query can be generated based on the cache structure code generator. When it is determined that the data processing request is a data writing request or a data deletion request, the data processing request can be abstracted as a data save. Specifically, it can be determined that it is: inserting an object into the database and writing it into the cache; inserting multiple objects into the database and writing them into the cache; updating an object in the database and deleting the cache; only updating the cache; updating multiple objects in the database and deleting the cache; deleting an object in the database and deleting the cache; deleting multiple objects in the database and deleting the cache. When it is determined that the data processing request is a data reading and writing request, the data processing request can be abstracted as a data query and a data save. Specifically, it can be determined that it is: querying a single object according to the primary key & foreign key, or querying multiple objects according to the primary key & foreign key list, and, inserting an object into the database and writing it into the cache; inserting multiple objects into the database and writing them into the cache; updating an object in the database and deleting the cache; only updating the cache; updating multiple objects in the database and deleting the cache. Furthermore, the data save code corresponding to the data save can be generated based on the cache structure code generator.
[0043] It should be noted that for service data, before generating the execution code corresponding to the data processing request, it is also necessary to pre-determine the request annotations for data processing requests of various request types. For example, it is necessary to determine the writing method, writing format, and writing rules corresponding to data writing, the reading parameters and reading depth corresponding to data reading, the writing method, writing format, writing rules, reading parameters, and reading depth corresponding to data reading and writing, and the deletion parameters and deletion method corresponding to data deletion.
[0044] Furthermore, the cache structure code generator can generate the execution code corresponding to the data processing request based on the data processing request and the request annotation corresponding to the data processing request.
[0045] In the embodiment of the present invention, after determining the request type of the data processing request, the execution code corresponding to the data processing request can be generated according to the request type of the data processing request and the request annotation of the data processing request of this request type set in advance, realizing the modular generation of the code and improving the development efficiency of data processing based on the cache.
[0046] Step 130: Execute the execution code to obtain the request result corresponding to the data processing request.
[0047] Specifically, after determining the execution code corresponding to the data processing request, the code can be executed to perform data writing, data reading, data reading and writing, or data deletion based on the cache, and obtain the request result corresponding to the data processing request, that is, realize writing data into the cache, reading data in the cache, reading data in the database and writing it into the cache, or deleting data in the cache.
[0048] It should be noted that when the data processing request executed based on the cache is a data query, the data processing request can be executed based on the cache before the data processing request executes the database operation. When the data processing request executed based on the cache is data writing or data deletion, the data processing request can be executed based on the cache after the data processing request executes the database operation.
[0049] In the embodiment of the present invention, by implementing the data processing request based on the cache to obtain the corresponding request result, compared with the prior art, the request result of the data processing request is determined based on the execution code of the modularly generated data, improving the data processing efficiency.
[0050] The data processing method provided by the embodiment of the present invention includes: intercepting the received data processing request based on the cache processing component aspect; determining the request type of the data processing request, and determining the execution code corresponding to the data processing request according to the request type; executing the execution code to obtain the request result corresponding to the data processing request. In the above technical solution, first, the data processing request for the database can be intercepted based on the cache processing component aspect, which is convenient for executing the data processing request based on the cache, reducing the number of accesses to the database, and improving the data processing efficiency and memory requirements. Second, the request type of the data processing request can be determined. After determining the request type of the data processing request, the execution code corresponding to the data processing request can be generated according to the request type of the data processing request and the request annotation of the data processing request of this request type set in advance, realizing the modular generation of the corresponding code for data processing, improving the development efficiency of data processing based on the cache. Furthermore, the data processing request can be executed based on the cache to obtain the corresponding request result. Compared with the prior art, the request result of the data processing request is determined by implementing the execution code of the data processing request generated modularly, improving the data processing efficiency.
[0051] Figure 2 FIG. is a flowchart of another data processing method provided by the embodiment of the present invention. The embodiment of the present invention is applicable to the situation where systematic data processing needs to be performed based on the cache. On the basis of the above embodiment, before intercepting the received data processing request based on the cache processing component aspect, "setting request annotations for data processing requests of various request types based on the cache processing component" is added. The explanations of the same or corresponding terms as those in the above embodiments are not repeated here. Refer to Figure 2 , the data processing method provided by the embodiment of the present invention includes:
[0052] Step 210, setting request annotations for data processing requests of various request types based on the cache processing component.
[0053] Among them, the request type of the data processing request is data writing, data reading, data reading and writing, or data deletion.
[0054] Specifically, a request annotation can be understood as the specific execution manner of a data processing request, and the request annotation can be in the form of a Java annotation. When the request type of the data processing request is data writing, the request annotation of the data processing request can include a writing manner, a writing format, and a writing rule; when the request type of the data processing request is data reading, the request annotation of the data processing request can include a reading parameter and a reading depth; when the request type of the data processing request is data reading and writing, the request annotation of the data processing request can include a writing manner, a writing format, a writing rule, a reading parameter, and a reading depth; when the request type of the data processing request is data deletion, the request annotation of the data processing request can include a deletion parameter and a deletion manner.
[0055] Of course, the request annotation further includes a preset key prefix and a key suffix obtained through input parameters. In practical applications, a key can also be custom-generated based on the request annotation.
[0056] In one implementation manner, step 210 can specifically include:
[0057] Setting a writing manner, a writing format, and a writing rule for a data processing request with a request type of data writing based on the cache processing component; setting a reading parameter and a reading depth for a data processing request with a request type of data reading based on the cache processing component; setting a writing manner, a writing format, a writing rule, a reading parameter, and a reading depth for a data processing request with a request type of data reading and writing based on the cache processing component; setting a deletion parameter and a deletion manner for a data processing request with a request type of data deletion based on the cache processing component.
[0058] Further, the writing manner is primary key writing or foreign key writing; the writing format is an object or a list; when the writing manner is primary key writing, the writing rule is: performing object writing or list writing according to the writing format of the data to be written included in the data processing request; when the writing manner is foreign key writing, the writing rule is: writing the data to be written included in the data processing request in the form of a foreign key into the cache.
[0059] Further, the reading parameter is the key of the data to be read, and the reading depth is reading through the database or not reading through the database.
[0060] Further, the deletion parameter is the key of the data to be deleted, and the deletion manner is determined by the data format of the data to be deleted.
[0061] Figure 3 The structural schematic diagram of the cache processing component in another data processing method provided by the embodiment of the present invention is as Figure 3As shown, the cache processing component can perform request settings on data processing requests. The cache processing component includes a cache processing component aspect for intercepting data processing requests acting on the database.
[0062] Specifically, the write method, write format, and write rules can be set for data processing requests with a request type of data writing based on the cache processing component. Specifically, the write method can be primary key writing or foreign key writing. The write format can be the data format written to the cache, including: object, list. When the write method is primary key writing, the write rule is: perform object writing or list writing according to the write format of the data to be written included in the data processing request. When the write method is foreign key writing, the write rule is: write the data to be written included in the data processing request to the cache in the form of a foreign key. For example, the read method of the primary key value can be written in the value of the foreign key writing. The read parameters and read depth can be set for data processing requests with a request type of data reading based on the cache processing component. Specifically, the read parameters can include a key composed of a key prefix and a key suffix, and the read depth can be reading through the database or not reading through the database. The write method, write format, write rules, read parameters, and read depth can be set for data processing requests with a request type of data read-write based on the cache processing component. As mentioned above, the write method can be primary key writing or foreign key writing. The write format can be the data format written to the cache, including: object, list. When the write method is primary key writing, the write rule is: perform object writing or list writing according to the write format of the data to be written included in the data processing request. When the write method is foreign key writing, the write rule is: write the data to be written included in the data processing request to the cache in the form of a foreign key. The read parameters can include a key composed of a key prefix and a key suffix, and the read depth can be reading through the database or not reading through the database. It is also possible to set whether to write the data read through the database to the cache after reading the data to be read for data processing requests with a request type of data read-write. The delete parameters and delete method can be set for data processing requests with a request type of data deletion based on the cache processing component. Specifically, the delete parameters can include a key composed of a key prefix and a key suffix, and the delete method is determined by the data format of the data to be deleted, generally defaulting to string. When deleting, the delete statement corresponding to the data format of the data to be deleted can be used to delete the data to be deleted.
[0063] In addition, it is also possible to configure batch writing based on a database listener for data processing requests of the data writing request type based on the cache processing component, configure batch reading based on a database listener for data processing requests of the data reading request type based on the cache processing component, and configure batch deletion based on a database listener for data processing requests of the data deletion request type based on the cache processing component.
[0064] When the service product is a health service, the service data consists of an order ID, a service package ID, a rights and interests ID, and rights and interests data. An order can include at least one service package. Therefore, the service package ID can be used to distinguish service packages within an order. A service package can include at least one right and interest. Therefore, the rights and interests ID can be used to distinguish rights and interests within a service package. The rights and interests data can be the usage status of the rights and interests, which can be unused, in use, or already used.
[0065] In practical applications, it is possible to set a cache description enumeration for data processing requests based on redisKeyEnum, including the prefix of the key and the timeout period.
[0066] For data writing, it is possible to set the written value based on saveKeyProperty.
[0067] For example, when the written key is the order ID, the value can be the service package ID in the service data, or the rights and interests ID, or the rights and interests data. When the written key is the service package ID, the value can be the rights and interests ID in the service data, or the rights and interests data. When the written key is the rights and interests ID, the value can be the rights and interests data in the service data. It is also possible to set the writing format for data writing of a single object based on entityType. When the data to be written is a single object, there are two type options for the writing format: String and List. It is also possible to set the writing format for data writing of a List object based on entityListType. When the data to be written is a List object, there are also two type options for the writing format: String and List. It is also possible to set whether to store the List object in a combined manner for data writing of a List object based on compose. When compose is true, the List object can be stored with the same key. When compose is false, the List object can be stored with multiple keys. It is also possible to set the foreign key writing method for data writing based on isForeignKey. When isForeignKey is true, the data to be written is written based on foreign key writing. When isForeignKey is false, the data to be written is written based on primary key writing.
[0068] When writing service data based on foreign key writes, after writing the order ID and service package ID as key-value pairs into the cache, the service package ID and entitlement ID can be continuously written as key-value pairs into the cache, and the entitlement ID and entitlement data can also be continuously written as key-value pairs into the cache, realizing the foreign key write of service data.
[0069] For data reading, the reading parameters can be set for data reading based on queryKeyProperty. Specifically, the key suffix of the data to be read can be set for data reading; the reading depth can also be set for data reading based on isBreakDown. Specifically, the data reading that penetrates to the database or the data reading that does not penetrate to the database can be set for data reading. When isBreakDown is true, in the case where the value corresponding to the reading parameter key cannot be found in the cache, it can penetrate to the database to read the value corresponding to the reading parameter key. When isBreakDown is false, in the case where the value corresponding to the reading parameter key cannot be found in the cache, the data is not read from the database either.
[0070] For data reading and writing, the write methods, write formats, and write rules related to data reading can be set based on entityType, entityListType, compose, and isForeignKey; the reading parameters and reading depth related to data reading can also be set based on queryKeyProperty and isBreakDown; similarly, whether to write the data read from the database into the cache after penetrating the database to read the data to be read can be set based on isBreakDownWrite. When isBreakDownWrite is true, the data read from the database can be written into the cache.
[0071] For data deletion, the deletion parameters can be set for data deletion based on keyName. Specifically, the keyName of the data to be deleted can be set for data deletion to delete the value corresponding to keyName; the deletion method can also be set for data deletion based on redisEnum. Data deletion can delete the corresponding data to be deleted in the cache based on this data deletion method. redisEnum defaults to string. When deleting the data to be deleted, the deletion statement corresponding to string can be used to delete the data to be deleted.
[0072] In the embodiments of the present invention, request annotations are set for data processing requests of various request types, providing a parameter basis for executing data processing requests based on the cache.
[0073] Step 220: Intercept the received data processing request based on the cache processing component aspect.
[0074] As mentioned above, for data processing requests for the database, the cache processing component aspect can intercept these data processing requests for the database so that, before or after the data processing request operates on the database, the data processing request is executed based on the cache.
[0075] In the embodiment of the present invention, intercepting the data processing request for the database based on the cache processing component aspect facilitates executing the data processing request based on the cache and improves the data processing efficiency.
[0076] Step 230: Determine the request type of the data processing request, and determine the execution code corresponding to the data processing request according to the request type.
[0077] In one implementation, step 230 may specifically include:
[0078] Determine the execution code corresponding to the data processing request of various request types according to the data processing requests of various request types and the request annotations of the data processing requests of various request types.
[0079] Specifically, first, it can be determined that the request type of the intercepted data processing request is data writing, data reading, data reading and writing, or data deletion. Second, according to the request type of the data request and the request annotation of the data processing request of this request type set in advance, the execution code corresponding to the data processing request is generated.
[0080] In practical applications, specific code class files can be generated through velocity, which will not be elaborated here.
[0081] In the embodiment of the present invention, after determining the request type of the data processing request, the execution code corresponding to the data processing request can be generated according to the request type of the data processing request and the request annotation of the data processing request of this request type set in advance, realizing the modular generation of code and improving the development efficiency of data processing based on the cache.
[0082] Step 240: Execute the execution code to obtain the request result corresponding to the data processing request.
[0083] Specifically, when the cache executes the data processing request, the key prefix and timeout time information of the service data can be obtained through redisKeyEnum.
[0084] When writing data, first, data writing can be performed based on the database to write the data to be written into the database. At this time, the data to be written that has been written into the database can be obtained. If the data to be written is empty or the writing result is a writing failure, there is no need to continue writing data to the cache. Otherwise, the transaction status of the database can be determined. When it is determined that the transaction status of the database is open, it indicates that the order ID, service package ID, entitlement ID, and entitlement data included in the service data have not all been written into the database. At this time, the service data can be temporarily stored in the cache save manager. When it is determined that the transaction status of the database is closed, it indicates that the order ID, service package ID, entitlement ID, and entitlement data included in the service data have all been written into the database. At this time, the order ID, service package ID, entitlement ID, and entitlement data included in the service data can be written into the cache. When the cache writes the service data, it can determine whether to perform a foreign key write based on the request annotation for data writing. When it is determined that isForeignKey is false, it indicates that data can be written into the cache based on the primary key write. Determine the data type of the data to be written as a single object or a List object. When it is determined that the data type of the data to be written is a List object and compose is true, the List object is merged into a string and written into the cache. When it is determined that isForeignKey is true, it indicates that data can be written into the cache based on the foreign key write. Specifically, the value in the data write can be set to: "primary key id: type". For example, the value in the data write can be set to "servicePackageId_1:String", indicating that the value can be obtained in the form of String from the data table with the key servicePackageId_1. In addition, when the cache save manager saves the service data, if multiple cache save statements have been recorded by the current thread, the pipeline function is opened for batch saving.
[0085] When reading data, data can be read from the cache according to the key in the request annotation. If the value corresponding to the key in the request annotation cannot be obtained from the cache, when it is determined that isBreakDown is false, it is determined that the data reading fails. When it is determined that isBreakDown is true, the database is penetrated to read the value corresponding to the key in the request annotation. If the format of the value is "primary key id: type", the primary key id is continued to be used as the key to further query the corresponding value until the data to be read is obtained.
[0086] When performing data reading and writing, the same logic as the aforementioned data writing and data reading can be executed. Moreover, when the data to be read is retrieved through the penetrated database and isBreakDownWrite is true, the data to be read retrieved through the penetrated database can be further written into the cache. Here, the method of writing the data to be read into the cache is the same as the aforementioned data writing.
[0087] When performing data deletion, the data to be deleted can be determined based on the keyName, and the deletion statement can be determined based on redisEnum to delete the data to be deleted based on the deletion statement. For example, when the data to be deleted is data in the Hash data structure, the data in the Hash data structure can be deleted based on the Hdel statement.
[0088] As described above, when it is determined that the data processing request is a data reading request, the data processing request can be abstracted as a data query. Specifically, it can be determined as: find(Long id), which queries a single object based on the primary key & foreign key, or findList(List <long>ids), query multiple objects according to the primary key & foreign key list. Furthermore, data query code corresponding to the data query can be generated based on the cache structure code generator; when it is determined that the data processing request is a data write request or a data delete request, the data processing request can be abstracted as data saving. Specifically, it can be determined as: Inset(Entity entity), insert an object into the database and write it into the cache; InsertList(List <entity>entity), insert multiple objects into the database and write to the cache; Udpate(Entity entity), update an object in the database and delete the cache; UpdateCache(Entity,entity), only update the cache; UpdateList(List <entity>entities), update multiple objects in the database and delete the cache; delete(Long id) deletes an object in the database and deletes the cache; delete(List <long>ids), delete multiple objects in the database and delete the cache. Similarly, when it is determined that the data processing request is a data read / write request, the data processing request can be abstracted into data query and data save. Specifically, it can be determined as follows: query a single object according to the primary key & foreign key, or query multiple objects according to the primary key & foreign key list, and insert an object into the database and write it into the cache; insert multiple objects into the database and write them into the cache; update an object in the database and delete the cache; only update the cache; update multiple objects in the database and delete the cache. Furthermore, the data save code corresponding to the data save can be generated based on the cache structure code generator.
[0089] In practical applications, to ensure the eventual consistency of the data in the cache and the database, binlake can be used to monitor the database Mysql. When changes in the database tables of orders, service packages, rights, and rights data are detected, the cache update method will be forcibly called to update the cache. The primary key cache can be updated based on the cache processing component without updating the foreign key cache. An open-source database listening tool such as canal can also be used to monitor the database Mysql.
[0090] In the embodiments of the present invention, after determining the request type of the data processing request, the execution code corresponding to the data processing request can be generated according to the request type of the data processing request and the request annotation of the data processing request of this request type set in advance, realizing the modular generation of the code and improving the development efficiency of data processing based on the cache.
[0091] The data processing method provided by the embodiment of the present invention includes: setting request annotations for data processing requests of various request types based on a cache processing component; intercepting the received data processing requests through a cache processing component aspect; determining the request type of the data processing request, and determining the execution code corresponding to the data processing request according to the request type; and executing the execution code to obtain the request result corresponding to the data processing request. In the above technical solution, first, request annotations can be set for data processing requests of various request types, providing a parameter basis for executing data processing requests based on the cache. The cache processing component aspect intercepts the data processing requests for the database to execute data processing requests based on the cache, reducing the number of accesses to the database, improving the efficiency of data processing and memory requirements. After determining the request type of the data processing request, the execution code corresponding to the data processing request can be generated according to the request type of the data processing request and the request annotations of the data processing requests of this request type set in advance, realizing the modular generation of the corresponding code for data processing, improving the development efficiency of data processing based on the cache. Furthermore, the data processing request can be executed based on the cache to obtain the corresponding request result. Compared with the prior art, the request result of the data processing request is determined based on the modularly generated execution code, improving the data processing efficiency. Moreover, the consistency of the data in the cache and the database is improved, enhancing the user experience.
[0092] Figure 4 FIG. is a schematic structural diagram of a data processing device provided by an embodiment of the present invention. This device and the data processing methods of the above embodiments belong to the same inventive concept. For the details not described in detail in the embodiment of the data processing device, reference can be made to the embodiments of the above data processing methods.
[0093] The specific structure of this data processing device is as Figure 4 shown and includes:
[0094] An interception module 410, configured to intercept the received data processing requests through a cache processing component aspect;
[0095] A determination module 420, configured to determine the request type of the data processing request, and determine the execution code corresponding to the data processing request according to the request type;
[0096] An execution module 430, configured to execute the execution code to obtain the request result corresponding to the data processing request.
[0097] On the basis of the above embodiment, this device further includes:
[0098] A setting module, configured to set request annotations for data processing requests of various request types based on a cache processing component.
[0099] In one implementation, the request type of the data processing request is data writing, data reading, data writing and reading, or data deletion.
[0100] Based on the above embodiments, a setting module is provided, specifically for:
[0101] Setting a writing method, a writing format, and a writing rule for a data processing request with a request type of data writing based on the cache processing component;
[0102] Setting a reading parameter and a reading depth for a data processing request with a request type of data reading based on the cache processing component;
[0103] Setting a writing method, a writing format, a writing rule, a reading parameter, and a reading depth for a data processing request with a request type of data writing and reading based on the cache processing component;
[0104] Setting a deletion parameter and a deletion method for a data processing request with a request type of data deletion based on the cache processing component.
[0105] In one implementation, the writing method is primary key writing or foreign key writing; the writing format is object or list; when the writing method is primary key writing, the writing rule is: performing object writing or list writing according to the writing format of the data to be written included in the data processing request; when the writing method is foreign key writing, the writing rule is: writing the data to be written included in the data processing request in the form of a foreign key to the cache.
[0106] In one implementation, the reading parameter is the key of the data to be read, and the reading depth is reading through the database or not reading through the database.
[0107] In one implementation, the deletion parameter is the key of the data to be deleted, and the deletion method is determined by the data format of the data to be deleted.
[0108] Based on the above embodiments, a determination module 420 is provided, specifically for:
[0109] Determining the request type of the data processing request; and determining the execution code corresponding to the data processing request of each request type according to the data processing requests of various request types and the request annotations of the data processing requests of various request types.
[0110] The data processing device provided by the embodiments of the present invention can execute the data processing method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the data processing method.
[0111] It should be noted that in the embodiments of the above data processing device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of mutual distinction and do not limit the protection scope of the present invention.
[0112] Figure 5 FIG. is a schematic structural diagram of a computer device provided by an embodiment of the present invention. Figure 5 FIG. shows a block diagram of an exemplary computer device 5 suitable for implementing the embodiments of the present invention. Figure 5 The shown computer device 5 is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.
[0113] As Figure 5 shown, the computer device 5 is presented in the form of a general-purpose computing electronic device. The components of the computer device 5 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).
[0114] The bus 18 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the multiple bus structures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0115] The computer device 5 typically includes a variety of computer system-readable media. These media can be any available media accessible by the computer device 5, including volatile and non-volatile media, removable and non-removable media.
[0116] The system memory 28 may include computer system-readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer device 5 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 34 can be used for reading and writing non-removable, non-volatile magnetic media ( Figure 5 not shown, commonly referred to as a "hard disk drive"). Although Figure 5 is not shown, and a disk drive for reading and writing a removable non-volatile disk (e.g., "floppy disk") and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 through one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0117] A program / utilities 40 having a set (at least one) of program modules 42 may be stored, for example, in the system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. The program modules 42 generally perform the functions and / or methods in the embodiments described in the present invention.
[0118] The computer device 5 may also communicate with one or more external devices 14 (e.g., a keyboard, a pointing device, a display 24, etc.), and may also communicate with one or more devices that enable a user to interact with the computer device 5, and / or communicate with any device that enables the computer device 5 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be through the input / output (I / O) interface 22. Moreover, the computer device 5 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 20. As Figure 5 shown, the network adapter 20 communicates with other modules of the computer device 5 through the bus 18. It should be understood that although Figure 5 not shown in the figure, other hardware and / or software modules may be used in combination with the computer device 5, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0119] The processing unit 16 executes various functional applications and page displays by running programs stored in the system memory 28, for example, implementing the data processing method provided by the embodiments of the present invention. The method includes:
[0120] Intercepting the received data processing request based on the cache processing component aspect;
[0121] Determining the request type of the data processing request, and determining the execution code corresponding to the data processing request according to the request type;
[0122] Execute the execution code to obtain the request result corresponding to the data processing request.
[0123] Of course, those skilled in the art can understand that the processor can also implement the technical solutions of the data processing methods provided in any embodiment of the present invention.
[0124] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements, for example, the data processing method provided in the embodiment of the present invention. The method includes:
[0125] Intercept the received data processing request based on the cache processing component aspect;
[0126] Determine the request type of the data processing request, and determine the execution code corresponding to the data processing request according to the request type;
[0127] Execute the execution code to obtain the request result corresponding to the data processing request.
[0128] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device.
[0129] The computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, 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, and the computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.
[0130] The program code contained on a computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the above.
[0131] The computer program code for performing the operations of the present invention can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, 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 can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0132] Those of ordinary skill in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Optionally, they can be implemented with program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be separately fabricated into individual integrated circuit modules, or multiple of them can be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
[0133] Note that the above is only the preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments here. Various obvious changes, re-adjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.< / long> < / entity> < / entity> < / long>
Claims
1. A data processing method, characterized in that, it includes: intercepting the received data processing request based on the cache processing component aspect; determining the request type of the data processing request, and determining the execution code corresponding to the data processing request according to the request type; executing the execution code to obtain the request result corresponding to the data processing request.
2. The data processing method according to claim 1, characterized in that, before intercepting the received data processing request based on the cache processing component aspect, it further includes: setting request annotations for data processing requests of various request types based on the cache processing component.
3. The data processing method according to claim 2, characterized in that, the request type of the data processing request is data writing, data reading, data reading and writing, or data deletion.
4. The data processing method according to claim 3, characterized in that, setting request annotations for data processing requests of various request types based on the cache processing component includes: setting the writing method, writing format, and writing rules for the data processing request with the request type of data writing based on the cache processing component; setting the reading parameters and reading depth for the data processing request with the request type of data reading based on the cache processing component; setting the writing method, writing format, writing rules, reading parameters, and reading depth for the data processing request with the request type of data reading and writing based on the cache processing component; setting the deletion parameters and deletion method for the data processing request with the request type of data deletion based on the cache processing component.
5. The data processing method according to claim 4, characterized in that, the writing method is primary key writing or foreign key writing; the writing format is object or list; when the writing method is primary key writing, the writing rule is: performing object writing or list writing according to the writing format of the data to be written included in the data processing request; when the writing method is foreign key writing, the writing rule is: writing the data to be written included in the data processing request into the cache in the form of a foreign key.
6. The data processing method according to claim 4, characterized in that, the reading parameter is the key of the data to be read, and the reading depth is reading through the database or not reading through the database.
7. The data processing method according to claim 4, characterized in that, the deletion parameter is the key of the data to be deleted, and the deletion method is determined by the data format of the data to be deleted.
8. The data processing method according to claim 2, characterized in that, determining the execution code corresponding to the data processing request according to the request type includes: determining the execution code corresponding to the data processing requests of various request types according to the data processing requests of various request types and the request annotations of the data processing requests of various request types.
9. A data processing device, characterized in that, it includes: an interception module for intercepting the received data processing request based on the cache processing component aspect; a determination module for determining the request type of the data processing request and determining the execution code corresponding to the data processing request according to the request type; An execution module for executing the execution code to obtain a request result corresponding to the data processing request.
10. A computer device, characterized in that the computer device includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the data processing method according to any one of claims 1-8.
11. A storage medium containing computer-executable instructions, characterized in that the computer-executable instructions are used to execute the data processing method according to any one of claims 1-8 when executed by a computer processor.