Method and apparatus for transmitting hierarchical data, electronic device, and storage medium
Patent Information
- Application Number
- CN202311077684.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-08-24
AI Technical Summary
[0003]本申请提供了一种层级结构数据的传输方法、装置、电子设备及存储介质,以解决服务端多次重复地向客户端传输相同的数据,浪费网络流量的问题
[0069] Compared with the prior art, the above-mentioned technical solution provided in this application has the following advantages: The method provided in this application receives a data acquisition request from a client through a server, determines the original returned data, and determines the idempotency code of each level of data in the original returned data. When it is determined that the data acquisition request needs to ensure idempotency, at least one first target idempotency code is parsed from the data acquisition request. Based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data, the original returned data is idempotent. Based on the idempotency verification result, the original returned data is processed accordingly to obtain the target returned data, which is then sent to the client. Each first target idempotency code corresponds to a cached data in the client's local cache. Since this application proposes to use a single level of data in the hierarchical structure data as the granularity and adopts a client-side caching and server-side idempotency verification method to ensure that multiple acquisition operations of the same level of data by the same client are executed only once, that is, to ensure idempotency, it can avoid transmitting duplicate data and save network traffic caused by multiple transmissions of duplicate data.
Smart Images

Figure CN117135223B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a method, apparatus, electronic device, and storage medium for transmitting hierarchical data. Background Technology
[0002] Currently, in scenarios where the same client repeatedly requests the same hierarchical data (such as Card protocol data) from the server, regardless of whether the hierarchical data has changed or only some of the hierarchical data has changed, the server always sends the complete hierarchical data to the client. This results in the server repeatedly transmitting the same hierarchical data, wasting network bandwidth. Summary of the Invention
[0003] This application provides a method, apparatus, electronic device, and storage medium for transmitting hierarchical data to solve the problem of the server repeatedly transmitting the same data to the client, thus wasting network bandwidth.
[0004] In a first aspect, this application provides a method for transmitting hierarchical structure data, the method comprising:
[0005] Receive a data acquisition request from the client, determine the original returned data, and determine the idempotency encoding of each level of data in the original returned data;
[0006] If it is determined that the data acquisition request needs to be idempotent, the following steps are performed:
[0007] At least one first target idempotency code is parsed from the data acquisition request, wherein each first target idempotency code corresponds to a cached data in the client's local cache;
[0008] Idempotency verification is performed on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data;
[0009] The original returned data is processed according to the idempotency check result to obtain the target returned data, which is then sent to the client. The target returned data includes at least the idempotency encoding of each level of data.
[0010] Optionally, the method further includes:
[0011] If it is determined that the data acquisition request does not need to guarantee idempotency, the idempotency encoding of each level of data in the original returned data is filled into the original returned data to obtain the target returned data, and the target returned data is sent to the client.
[0012] Optionally, the method further includes:
[0013] After receiving the data acquisition request from the client, the data acquisition request is parsed;
[0014] If an idempotent encoded field is parsed from the data acquisition request, it is determined that the data acquisition request needs to guarantee idempotency; if the idempotent encoded field is not parsed from the data acquisition request, it is determined that the data acquisition request does not need to guarantee idempotency.
[0015] Optionally, the step of performing idempotency verification on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the target data includes:
[0016] For each level of data in the original returned data, determine whether there exists a first target idempotent code that is consistent with the idempotent code of the level data;
[0017] The step of processing the original returned data according to the idempotency check result to obtain the target returned data includes:
[0018] If the idempotency check result indicates the existence of a first target idempotency code that is consistent with the idempotency code of the hierarchical data, the idempotency code of the hierarchical data is added to the original returned data and the hierarchical data is deleted from the original returned data to obtain the target returned data;
[0019] If the idempotency check result indicates that there is no first target idempotency code that is consistent with the idempotency code of the hierarchical data, the idempotency code of the hierarchical data is added to the original returned data to obtain the target returned data.
[0020] Optionally, determining the idempotency encoding of each level of data in the original returned data includes:
[0021] For each level of data in the original returned data, a message digest of the data at that level is generated using a set algorithm;
[0022] The information digest is determined as the idempotent encoding of the hierarchical data.
[0023] Secondly, this application provides another method for transmitting hierarchical structure data, the method comprising:
[0024] A data retrieval request is sent to the server, enabling the server to receive the request, determine the original returned data, and determine the idempotency code for each level of data in the original returned data. If it is determined that the data retrieval request needs to guarantee idempotency, at least one first target idempotency code is parsed from the data retrieval request, wherein each first target idempotency code corresponds to a cached data in the client's local cache. Based on the at least one first target idempotency code and the idempotency code for each level of data in the original returned data, the original returned data is subjected to idempotency verification. Based on the idempotency verification result, the original returned data is processed accordingly to obtain target returned data, which is then sent to the client.
[0025] The system receives the target return data from the server and parses out the second target idempotency code that meets the set conditions from the target return data. The set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target return data.
[0026] Retrieve the target cache data corresponding to the second target idempotency encoding from the local cache, and fill the target return data with the target cache data as the hierarchical data corresponding to the second target idempotency encoding to obtain the original return data.
[0027] Optionally, the method further includes:
[0028] Parse the third target idempotency code that does not meet the set conditions and the corresponding hierarchical data from the target returned data;
[0029] The third target idempotency code and its corresponding hierarchical data are stored in the local cache.
[0030] Optionally, sending a data retrieval request to the server includes:
[0031] If it is determined that the local cache is not empty, an idempotency encoding field is added to the data retrieval request, and the idempotency encoding in the local cache is used as the value of the idempotency encoding field;
[0032] A data retrieval request with the idempotency encoding field added is sent to the server, so that the server, after parsing the idempotency encoding field from the received data retrieval request, determines that the received data retrieval request needs to guarantee idempotency.
[0033] Optionally, the method further includes:
[0034] A lifetime is set for each idempotent code and its corresponding hierarchical data in the local cache, so that when the lifetime is reached, the corresponding idempotent code and its corresponding hierarchical data are deleted from the local cache.
[0035] Thirdly, this application provides a device for transmitting hierarchical data, the device comprising:
[0036] The request receiving module is used to receive data retrieval requests from clients;
[0037] An idempotent coding module is used to determine the original returned data and to determine the idempotency coding of each level of data in the original returned data;
[0038] The request parsing module is used to parse at least one first target idempotency code from the data acquisition request when it is determined that the data acquisition request needs to ensure idempotency, wherein each first target idempotency code corresponds to a cached data in the client's local cache;
[0039] An idempotency verification module is used to perform idempotency verification on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data;
[0040] The data processing module is used to process the original returned data according to the idempotency verification result to obtain the target returned data, and to send the target returned data to the client, wherein the target returned data includes at least the idempotency encoding of each level of data.
[0041] Optionally, the data processing module is further configured to:
[0042] If it is determined that the data acquisition request does not need to guarantee idempotency, the idempotency encoding of each level of data in the original returned data is filled into the original returned data to obtain the target returned data, and the target returned data is sent to the client.
[0043] Optionally, the device further includes:
[0044] The judgment module is used to parse the data acquisition request after receiving the data acquisition request from the client;
[0045] If an idempotent encoded field is parsed from the data acquisition request, it is determined that the data acquisition request needs to guarantee idempotency; if the idempotent encoded field is not parsed from the data acquisition request, it is determined that the data acquisition request does not need to guarantee idempotency.
[0046] Optionally, the idempotency verification module is specifically used for:
[0047] For each level of data in the original returned data, determine whether there exists a first target idempotent code that is consistent with the idempotent code of the level data;
[0048] The data processing module includes:
[0049] The first processing unit is configured to, when the idempotency check result indicates the existence of a first target idempotency code that is consistent with the idempotency code of the hierarchical data, add the idempotency code of the hierarchical data to the original returned data and delete the hierarchical data from the original returned data to obtain the target returned data;
[0050] The second processing unit is used to add the idempotency code of the hierarchical data to the original returned data when the idempotency check result indicates that there is no first target idempotency code that is consistent with the idempotency code of the hierarchical data, so as to obtain the target returned data.
[0051] Optionally, the idempotent coding module is specifically used for:
[0052] For each level of data in the original returned data, a message digest of the data at that level is generated using a set algorithm;
[0053] The information digest is determined as the idempotent encoding of the hierarchical data.
[0054] Fourthly, this application provides another method for transmitting hierarchical data, the method comprising:
[0055] A request sending module is configured to send a data retrieval request to the server, so that the server receives the data retrieval request, determines the original returned data, and determines the idempotency encoding of each level of data in the original returned data; if it is determined that the data retrieval request needs to guarantee idempotency, at least one first target idempotency encoding is parsed from the data retrieval request, wherein each first target idempotency encoding corresponds to a cached data in the client's local cache; the original returned data is idempotently verified based on the at least one first target idempotency encoding and the idempotency encoding of each level of data in the original returned data; the original returned data is processed accordingly based on the idempotency verification result to obtain target returned data, and the target returned data is sent to the client;
[0056] A data receiving module is used to receive the target returned data from the server.
[0057] The data parsing module is used to parse a second target idempotency code that meets set conditions from the target returned data, wherein the set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target returned data;
[0058] The data filling module is used to obtain target cache data corresponding to the second target idempotency code from the local cache, and fill the target returned data with the target cache data as hierarchical data corresponding to the second target idempotency code to obtain the original returned data.
[0059] Optionally, the device further includes:
[0060] The data storage module is used to parse the third target idempotency code that does not meet the set conditions and the hierarchical data corresponding to the third target idempotency code from the target returned data;
[0061] The third target idempotency code and its corresponding hierarchical data are stored in the local cache.
[0062] Optionally, the request sending module includes:
[0063] If it is determined that the local cache is not empty, an idempotency encoding field is added to the data retrieval request, and the idempotency encoding in the local cache is used as the value of the idempotency encoding field;
[0064] A data retrieval request with the idempotency encoding field added is sent to the server, so that the server, after parsing the idempotency encoding field from the received data retrieval request, determines that the received data retrieval request needs to guarantee idempotency.
[0065] Optionally, the device further includes:
[0066] The cleanup module is used to set a lifetime for each idempotent code and its corresponding hierarchical data in the local cache, so that when the lifetime is reached, the corresponding idempotent code and its corresponding hierarchical data will be deleted from the local cache.
[0067] Fifthly, this application provides an electronic device, including: a processor and a memory, wherein the processor is configured to execute a transmission program for hierarchical structure data stored in the memory, so as to implement the hierarchical structure data transmission method described in any one of the first or second aspects.
[0068] In a sixth aspect, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the method for transmitting hierarchical data as described in the first or second aspect.
[0069] Compared with the prior art, the above-mentioned technical solution provided in this application has the following advantages: The method provided in this application receives a data acquisition request from a client through a server, determines the original returned data, and determines the idempotency code of each level of data in the original returned data. When it is determined that the data acquisition request needs to ensure idempotency, at least one first target idempotency code is parsed from the data acquisition request. Based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data, the original returned data is idempotent. Based on the idempotency verification result, the original returned data is processed accordingly to obtain the target returned data, which is then sent to the client. Each first target idempotency code corresponds to a cached data in the client's local cache. Since this application proposes to use a single level of data in the hierarchical structure data as the granularity and adopts a client-side caching and server-side idempotency verification method to ensure that multiple acquisition operations of the same level of data by the same client are executed only once, that is, to ensure idempotency, it can avoid transmitting duplicate data and save network traffic caused by multiple transmissions of duplicate data.
[0070] The method provided in this application embodiment sends a data acquisition request to the server, receives target return data from the server, and parses out a second target idempotency code that meets set conditions from the target return data. The set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target return data; target cache data corresponding to the second target idempotency code is obtained from the local cache, and the target cache data is used as hierarchical data corresponding to the second target idempotency code to fill the target return data to obtain the original return data. Since this application embodiment proposes to use a single hierarchical data in the hierarchical structure data as the granularity, and adopts a client-side caching and server-side idempotency verification method to ensure that multiple acquisition operations of the same client for the same hierarchical data are executed only once, that is, to ensure idempotency, it can avoid transmitting duplicate data and save network traffic caused by multiple transmissions of duplicate data. Attached Figure Description
[0071] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0072] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0073] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0074] Figure 1 A flowchart illustrating an embodiment of a method for transmitting hierarchical data provided in this application;
[0075] Figure 2 An example of processing the raw returned data into the target returned data;
[0076] Figure 3 A flowchart illustrating an embodiment of another method for transmitting hierarchical data provided in this application;
[0077] Figure 4 An example of processing the raw returned data into the target returned data;
[0078] Figure 5 A flowchart illustrating an embodiment of another method for transmitting hierarchical data provided in this application;
[0079] Figure 6 An example of restoring the target returned data to the original returned data;
[0080] Figure 7 A flowchart illustrating an embodiment of another method for transmitting hierarchical data provided in this application;
[0081] Figure 8 A flowchart illustrating an embodiment of another method for transmitting hierarchical data provided in this application;
[0082] Figure 9 Here is an example of the original returned data;
[0083] Figure 10 An example of returning data to a target;
[0084] Figure 11 A block diagram illustrating an embodiment of a hierarchical data transmission device provided in this application;
[0085] Figure 12A block diagram illustrating another embodiment of a hierarchical data transmission apparatus provided in this application.
[0086] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0087] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0088] The following disclosure provides numerous different embodiments or examples for implementing various structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of the invention. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0089] This application provides a method for transmitting hierarchical data. To facilitate understanding of the method for transmitting hierarchical data provided in the embodiments of this application, the application scenarios involved in the embodiments of this application are first described as follows:
[0090] In this application's embodiments, "client" refers to the same client, and "data acquisition request" refers to a request to acquire the same data. In other words, the application scenario involved in this application's embodiments is a scenario where the same client repeatedly requests the same data from the server, such as a client repeatedly refreshing a page. Furthermore, in the application scenario involved in this application's embodiments, the data requested by the client is hierarchical structure data, which refers to data containing multiple levels. For example, Card protocol data includes three levels: Page, Card, and Block. Of course, the levels can be further refined, such as to image and mark levels. Currently, the Card protocol is commonly used in page transmission scenarios, meaning that the entire page data is abstracted into three levels: Page, Card, and Block.
[0091] Taking page data as an example, in practical applications, there are situations where the entire page data remains unchanged or only some levels of data change. For instance, only the data at a specific Card level might change. If the server sends the entire page data to the client every time, it will result in the server repeatedly transmitting the same data, wasting network bandwidth.
[0092] In response, this application proposes to use individual hierarchical data in the hierarchical structure data as the granularity, and adopt client caching and server idempotency verification to ensure that multiple acquisition operations of the same client for the same hierarchical data are executed only once, that is, to ensure idempotency, so as to save network traffic caused by multiple transmissions of duplicate data.
[0093] The following explanation describes the method for transmitting hierarchical data provided in this application from the perspectives of the server, the client, and the interaction between the server and the client.
[0094] Figure 1 This is a flowchart illustrating an embodiment of a method for transmitting hierarchical data, as provided in this application. Figure 1 The process shown applies to the server side, which can be a single server or a server cluster consisting of multiple devices; no specific limitation is made here. For example... Figure 1 As shown, the process includes the following steps:
[0095] Step 101: The server receives a data acquisition request from the client, determines the original returned data, and determines the idempotency encoding of each level of data in the original returned data; if it is determined that the data acquisition request needs to ensure idempotency, steps 102 to 104 are executed.
[0096] Based on the above description of the application scenarios involved in the embodiments of this application, the original returned data here is hierarchical structure data.
[0097] The aforementioned data retrieval request can be the first data retrieval request sent by the client to the server for a certain hierarchical data structure, or it can be a non-first data retrieval request sent by the client to the server for that hierarchical data structure. Here, the concept of "first" can be defined by a certain period of time (e.g., in days), or it can be without a defined range. This application embodiment does not specifically limit it in this way.
[0098] In this embodiment, regardless of whether it is the first data retrieval request or not, the server will determine the corresponding original return data, such as page data, upon receiving the data retrieval request. Unlike existing technologies, after determining the original return data, the server does not immediately send it to the client. Instead, it processes it according to the method provided in this embodiment to remove duplicate data, and finally sends the target return data that does not contain duplicate data to the client, thereby saving network traffic caused by multiple transmissions of duplicate data.
[0099] Specifically, as shown in step 101 above, after the server determines the original returned data, it determines the idempotency encoding of each level of data in the original returned data. Then, if it is determined that the data acquisition request needs to guarantee idempotency, steps 102 to 104 are executed. Here, if the data acquisition request needs to guarantee idempotency, it means that the data acquisition request is not the first data acquisition request sent by the client to the server. In this case, it is necessary to guarantee the idempotency of each level of data in the original returned data.
[0100] In one embodiment, the specific implementation of determining the idempotency code of each level of data in the original returned data includes: for each level of data in the original returned data, generating a message digest of the level data using a set algorithm, and determining the message digest as the idempotency code of the level data. Optionally, the set algorithm is the MD5 message digest algorithm, and correspondingly, the message digest is the MD5 value. It can be understood that the MD5 values of different levels of data are different, that is, the idempotency code of the level data is unique.
[0101] Taking Card protocol data as an example, for Page-level data, the message digest of the entire Page-level data is calculated and used as the idempotency code for the Page-level data; for Card-level data, the message digest of each Card-level data is calculated and used as the idempotency code for the Card-level data; for Block-level data, the message digest of each Block-level data is calculated and used as the idempotency code for the Block-level data.
[0102] In one embodiment, after receiving a data retrieval request from a client, the server determines whether the data retrieval request needs to guarantee idempotency by: parsing the data retrieval request; if an idempotency-encoded field is parsed from the data retrieval request, it is determined that the data retrieval request needs to guarantee idempotency; if no idempotency-encoded field is parsed from the data retrieval request, it is determined that the data retrieval request does not need to guarantee idempotency. How the client determines whether to add an idempotency-encoded field to the data retrieval request will be explained in the process described below, and will not be detailed here.
[0103] Step 102: The server parses at least one first target idempotency code from the data retrieval request, wherein each first target idempotency code corresponds to a cached data in the client's local cache.
[0104] As described above, when the data retrieval request needs to guarantee idempotency, the data retrieval request contains an idempotency encoding field. Therefore, when the data retrieval request needs to guarantee idempotency, the server can parse at least one idempotency encoding (referred to as the first target idempotency encoding for convenience) from the data retrieval request. It should be noted that each first target idempotency encoding corresponds to a cached data in the client's local cache. How the client stores the idempotency encoding and its corresponding cached data in its local cache will be explained in the process described below, and will not be detailed here.
[0105] Step 103: The server performs idempotency verification on the original returned data based on at least one first target idempotency code and the idempotency code of each level of data in the target data.
[0106] Step 104: The server processes the original returned data according to the idempotency check result to obtain the target returned data, and sends the target returned data to the client. The target returned data includes at least the idempotency encoding of each level of data.
[0107] The following provides a unified explanation of steps 103 and 104:
[0108] As described above, when the data retrieval request needs to guarantee idempotency, the request carries at least one first target idempotency code, and the client's local cache contains cached data corresponding to this first target idempotency code. Based on this, the server can avoid repeatedly returning the hierarchical data corresponding to the first target idempotency code to the client, thereby avoiding the transmission of duplicate data and saving network traffic caused by multiple transmissions of duplicate data.
[0109] In response, the server can perform idempotency verification on the original returned data based on at least one first target idempotency code and the idempotency code of each level of data in the target returned data. Based on the idempotency verification result, it can determine whether the original returned data contains duplicate data. Then, based on the idempotency verification result, the server can process the original returned data accordingly to obtain the target returned data and send the target returned data to the client.
[0110] In one embodiment, the specific implementation of idempotency verification of the original returned data based on at least one first target idempotency code and the idempotency codes of each level of data in the target data includes: for each level of data in the original returned data, determining whether there exists a first target idempotency code consistent with the idempotency code of that level of data. Correspondingly, the specific implementation of processing the original returned data according to the idempotency verification result to obtain the target returned data includes: if the idempotency verification result indicates the existence of a first target idempotency code consistent with the idempotency code of that level of data, adding the idempotency code of that level of data to the original returned data and deleting that level of data from the original returned data to obtain the target returned data. This ensures that the target returned data no longer contains duplicate data, thereby avoiding the transmission of duplicate data and saving network traffic caused by multiple transmissions of duplicate data. Adding the idempotency code of that level of data to the original returned data enables the client to find the corresponding cached data from its local cache based on the idempotency code, and then reassembles the found cached data and the received target returned data to obtain the original returned data, ensuring that the client can completely obtain the data it needs. The implementation of this client will be explained in the process described below, and will not be detailed here.
[0111] Furthermore, if the idempotency check result indicates that there is no first target idempotency code that matches the idempotency code of the data at that level, the idempotency code of the data at that level is added to the original returned data to obtain the target returned data. Adding the idempotency code of the data at that level to the original returned data allows the client to store the idempotency code and the corresponding level data. This way, when retrieving the same level data next time, the idempotency code can be included in the data retrieval request, preventing the server from returning duplicate data to the client. This avoids transmitting duplicate data and saves network traffic caused by multiple transmissions of duplicate data. How this is implemented on the client side will be explained in the process described below, and will not be detailed here.
[0112] For example, the client sends a data retrieval request to the server for the first time. The data retrieval request carries an idempotent encoding field idpts, and the idpts field includes the idempotent encoding: fb4c537a5e309dfff9e57c829d23b0ea.
[0113] After receiving the data retrieval request, the server obtains the original returned data and determines the idempotency encoding of each level of data in the original returned data, as shown below. Figure 2 As shown in the left figure. Next, for each level of data in the original returned data, the server determines whether there exists a first target idempotent code that matches the idempotent code of that level of data. By comparison, it can be seen that the data retrieval request carries the idempotent code of the Page level data in the original returned data. At this point, the server deletes the Page level data from the original returned data but retains its idempotent code, obtaining the target returned data. See [link to target returned data]. Figure 2 The right image in the text.
[0114] Therefore, when data retrieval requests require idempotency, if the client's local cache already stores a portion of the hierarchical data from the original returned data, the server will not return that portion of hierarchical data to the client. This avoids transmitting duplicate data and saves network traffic caused by multiple transmissions of duplicate data. Simultaneously, the server returns the idempotency code of that portion of hierarchical data to the client, enabling the client to retrieve the corresponding data from its local cache based on the idempotency code in the received target returned data. The client can then reconstruct the original returned data using the data retrieved from its local cache and the received target returned data, ensuring that the client obtains the complete data it needs. The specific operations performed by the client after receiving the target returned data will be explained in the process described below and will not be detailed here.
[0115] The method provided in this application embodiment receives a data acquisition request from a client, determines the original returned data, and determines the idempotency code of each level of data in the original returned data. When it is determined that the data acquisition request needs to guarantee idempotency, at least one first target idempotency code is parsed from the data acquisition request. Based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data, the original returned data is idempotent. Based on the idempotency verification result, the original returned data is processed accordingly to obtain the target returned data, which is then sent to the client. Each first target idempotency code corresponds to a cached data in the client's local cache. Since this application embodiment proposes to use a single level of data in the hierarchical structure data as the granularity, and adopts client caching and server idempotency verification to ensure that multiple acquisition operations of the same level of data by the same client are executed only once, i.e., idempotency is guaranteed, it can avoid transmitting duplicate data and save network traffic caused by multiple transmissions of duplicate data.
[0116] Figure 3A flowchart illustrating an embodiment of another method for transmitting hierarchical data as provided in this application. Figure 3 The process shown applies to the server side, which can be a single server or a server cluster consisting of multiple devices; no specific limitation is made here. For example... Figure 3 As shown, the process includes the following steps:
[0117] Step 301: The server receives a data acquisition request from the client, determines the original returned data, and determines the idempotency encoding of each level of data in the original returned data; if it is determined that the data acquisition request needs to guarantee idempotency, steps 302 to 304 are executed; if it is determined that the data acquisition request does not need to guarantee idempotency, step 305 is executed.
[0118] Step 302: The server parses at least one first target idempotency code from the data retrieval request, wherein each first target idempotency code corresponds to a cached data in the client's local cache.
[0119] Step 303: The server performs idempotency verification on the original returned data based on at least one first target idempotency code and the idempotency code of each level of data in the target data.
[0120] Step 304: The server processes the original returned data according to the idempotency check result to obtain the target returned data, and sends the target returned data to the client. The target returned data includes at least the idempotency encoding of each level of data.
[0121] For a detailed description of steps 301 to 304 above, please refer to the above. Figure 1 The process shown is not repeated here.
[0122] Step 305: The server fills the original returned data with the idempotency encoding of each level of data in the original returned data to obtain the target returned data, and then sends the target returned data to the client.
[0123] Typically, when a client sends a data retrieval request to a server for the first time, idempotency is not required. Therefore, in one embodiment, the server can determine whether the received data retrieval request is the client's first data retrieval request. If so, it can be determined that the received data retrieval request does not need to guarantee idempotency. Optionally, after receiving a data retrieval request, the server can record the client's identifier locally so that it can determine whether the currently received data retrieval request is the client's first data retrieval request based on this record. Of course, other specific implementation methods may exist in practice, and this application embodiment does not specifically limit them.
[0124] In one embodiment, the server determines whether the data retrieval request needs to guarantee idempotency by parsing the data retrieval request. If an idempotency-encoded field is parsed from the data retrieval request, the server determines that the data retrieval request needs to guarantee idempotency; if no idempotency-encoded field is parsed from the data retrieval request, the server determines that the data retrieval request does not need to guarantee idempotency. How the client determines whether to add an idempotency-encoded field to the data retrieval request will be explained in the process described below, and will not be detailed here.
[0125] If the server determines that the data retrieval request does not need to guarantee idempotency, it fills the original returned data with the idempotency encoding of each level of data to obtain the target returned data, and then sends the target returned data to the client.
[0126] For example, the original returned data is as follows: Figure 4 As shown, by filling the original returned data with the idempotency encoding of each level of data, the following is obtained: Figure 4 The target returned in the example is data.
[0127] Figure 3 The method described above adds idempotency encoding to the hierarchical data in the original returned data so that the client can store the idempotency encoding and the corresponding hierarchical data. This allows the client to carry the idempotency encoding in the data retrieval request the next time the same hierarchical data is retrieved, preventing the server from returning duplicate data to the client. This avoids transmitting duplicate data and saves network traffic caused by transmitting duplicate data multiple times.
[0128] Figure 5 This is a flowchart illustrating an embodiment of a method for transmitting hierarchical data as provided in this application. Figure 5 The process shown applies to the client side, which can be an application running in a separate process, a sub-application (app) embedded in the client and independent of the main page, a function running on a web browser (also known as a WebApp), an app embedded in an email, etc., without limitation. Figure 5 As shown, the process includes the following steps:
[0129] Step 501: The client sends a data retrieval request to the server.
[0130] The data retrieval request in step 501 needs to be idempotent. Therefore, after receiving the data retrieval request, the server can proceed as described above. Figure 1 The process described in the illustrated flow is executed to obtain the target return data, which is then sent to the client. For the specific server-side processing, please refer to the above. Figure 1The descriptions in the process shown will not be repeated here.
[0131] In one embodiment, the specific implementation of the client sending a data retrieval request that needs to be idempotent to the server includes: if it is determined that the local cache is not empty, adding an idempotent encoding field to the data retrieval request (for example, adding an idempotent encoding field to the header of the data retrieval request), and using the idempotent encoding in the local cache as the value of the idempotent encoding field; sending the data retrieval request with the added idempotent encoding field to the server, so that the server can determine that the received data retrieval request needs to be idempotent if it parses the idempotent encoding field from the received data retrieval request.
[0132] Step 502: The client receives the target return data from the server and parses out the second target idempotency code that meets the set conditions from the target return data. The set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target return data.
[0133] Step 503: The client retrieves the target cache data corresponding to the second target idempotency encoding from the local cache, and fills the target returned data with the target cache data as the hierarchical data corresponding to the second target idempotency encoding to obtain the original returned data.
[0134] From the above Figure 1 As can be seen from the description in the process, if a certain idempotent code and its corresponding cached data are stored in the client's local cache, the server will no longer send the hierarchical data corresponding to the idempotent code to the client repeatedly. In other words, the hierarchical data corresponding to the second target idempotent code mentioned above has been stored in the client's local cache.
[0135] Therefore, after the client parses the second target idempotency encoded data that meets the set conditions from the target returned data, it retrieves the target cache data corresponding to the second target idempotency encoding from the local cache, and fills the target returned data with the target cache data as the hierarchical data corresponding to the second target idempotency encoding to obtain the original returned data.
[0136] For example, the client receives, such as Figure 6 The left image shows the target returned data, from which the second target idempotency code satisfying the set conditions is parsed: fb4c537a5e309dfff9e57c829d23b0ea. The client then retrieves the cached data corresponding to this second target idempotency code from its local cache, and uses this cached data as the hierarchical data corresponding to the second target idempotency code to fill the target returned data, resulting in the following... Figure 6 The original returned data is illustrated in the right-hand image.
[0137] The method provided in this application embodiment sends a data acquisition request to the server, receives target return data from the server, and parses out a second target idempotency code that meets set conditions from the target return data. The set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target return data; target cache data corresponding to the second target idempotency code is obtained from the local cache, and the target cache data is used as hierarchical data corresponding to the second target idempotency code to fill the target return data to obtain the original return data. Since this application embodiment proposes to use a single hierarchical data in the hierarchical structure data as the granularity, and adopts a client-side caching and server-side idempotency verification method to ensure that multiple acquisition operations of the same client for the same hierarchical data are executed only once, that is, to ensure idempotency, it can avoid transmitting duplicate data and save network traffic caused by multiple transmissions of duplicate data.
[0138] Figure 7 This is a flowchart illustrating an embodiment of a method for transmitting hierarchical data as provided in this application. Figure 7 The process shown is applied to the client, such as Figure 7 As shown, the process includes the following steps:
[0139] Step 701: The client sends a data retrieval request to the server.
[0140] Step 702: The client receives the target return data from the server. If the second target idempotency code that meets the set conditions is parsed from the target return data, step 703 is executed. If the third target idempotency code that does not meet the set conditions and the hierarchical data corresponding to the third target idempotency code are parsed from the target return data, step 704 is executed.
[0141] Step 703: The client retrieves the target cache data corresponding to the second target idempotency encoding from the local cache, and fills the target returned data with the target cache data as the hierarchical data corresponding to the second target idempotency encoding to obtain the original returned data.
[0142] Step 704: The client stores the idempotency encoding of the third target and its corresponding hierarchical data in the local cache.
[0143] From the above Figure 1As described in the process diagram, if the client's local cache does not contain a certain idempotent code and its corresponding cached data, the server will send the idempotent code and its corresponding hierarchical data to the client. This means that the hierarchical data corresponding to the aforementioned third-target idempotent code is not stored in the client's local cache. Therefore, the client can store the third-target idempotent code and its corresponding hierarchical data in its local cache so that the next time data is requested, the client can include the third-target idempotent code in the data retrieval request. This prevents the server from returning the hierarchical data corresponding to the third-target idempotent code to the client, thus avoiding the transmission of duplicate data and saving network traffic caused by multiple transmissions of duplicate data.
[0144] For example, suppose the client receives, as follows: Figure 4 The target returned data in the example is processed as described above. The client will parse it to obtain 6 third target idempotency codes, and then add these 6 third target idempotency codes and their corresponding hierarchical data to the local cache.
[0145] Figure 7 The method described above uses client-side caching and server-side idempotency checks at the granularity of individual hierarchical data to ensure that multiple retrieval operations of the same client for the same level of data are executed only once, thus guaranteeing idempotency. This avoids transmitting duplicate data and saves network traffic caused by transmitting duplicate data multiple times.
[0146] In addition, Figure 5 and Figure 7 Building upon the illustrated process, the client can further perform the following steps: Set a lifetime for each idempotent code and its corresponding hierarchical data in the local cache, so that when the lifetime is reached, the idempotent code and its corresponding hierarchical data are deleted from the local cache. This process prevents the client cache from expanding indefinitely, thus avoiding excessive consumption of client storage space and impacting client performance.
[0147] Figure 8 A flowchart illustrating an embodiment of a method for transmitting hierarchical data as provided in this application. (See attached flowchart.) Figure 8 As shown, the process includes the following steps:
[0148] Step 801: The client sends a data retrieval request to the server for the first time.
[0149] The initial data retrieval request does not include an idempotency-encoded field.
[0150] Step 802: The server receives the first data acquisition request, determines the original returned data, and determines the idempotency encoding of each level of data in the original returned data.
[0151] Step 803: The server fills the original returned data with the idempotency encoding of each level of data in the original returned data to obtain the target returned data, and then sends the target returned data to the client.
[0152] Step 804: The client receives the target return data from the server, and parses out the third target idempotency code that does not meet the set conditions and the hierarchical data corresponding to the third target idempotency code from the target return data.
[0153] Step 805: The client stores the idempotency encoding of the third target and its corresponding hierarchical data in the local cache.
[0154] Step 806: The client sends a data retrieval request to the server again. In this data retrieval request, the client adds an idempotency encoding field and uses the idempotency encoding in the local cache as the value of the idempotency encoding field.
[0155] The term "again" here generally refers to anything other than the first time.
[0156] Step 807: The server receives the data retrieval request sent by the client again, determines the original returned data, and determines the idempotency encoding of each level of data in the original returned data.
[0157] Step 808: The server parses at least one first target idempotency code from the data retrieval request.
[0158] Step 809: For each level of data in the original returned data, the server determines whether there is a first target idempotent code that is consistent with the idempotent code of that level of data. If it exists, proceed to step 810; otherwise, proceed to step 811.
[0159] Step 810: The server adds idempotency encoding of the hierarchical data to the original returned data and deletes the hierarchical data from the original returned data to obtain the target returned data. Then, proceed to step 812.
[0160] Step 811: The server adds idempotency encoding of the hierarchical data to the original returned data to obtain the target returned data.
[0161] Step 812: The client receives the target return data from the server and parses out the second target idempotency code that meets the set conditions from the target return data.
[0162] Step 813: The client retrieves the target cache data corresponding to the second target idempotency encoding from the local cache, and fills the target returned data with the target cache data as the hierarchical data corresponding to the second target idempotency encoding to obtain the original returned data.
[0163] The following specific examples will be used to explain steps 801 to 813 above:
[0164] Assuming the hierarchical structure of the original returned data is as follows: Figure 9 As shown, it includes Page-level data, Card1-level data, Card2-level data, Card3-level data, Block1-level data, Block2-level data, and Block3-level data.
[0165] When a client sends a data retrieval request to a server for the first time, the server adds idempotent encoding of each level of data to the original returned data to obtain the target returned data, and then sends the target returned data to the client.
[0166] The client receives the data returned by the target, parses out the data of each level and the corresponding idempotency code, and stores it in the local cache. The local cache is shown in Table 1 below:
[0167] Table 1
[0168]
[0169]
[0170] Subsequently, the client sends another data retrieval request to the server, carrying the seven idempotency codes from Table 1 above. Assuming that the Block1 level data in the original returned data has changed, the idempotency codes for the Block1, Card1, and Page level data will change, while the idempotency codes for the Block2, Block3, Card2, and Card3 level data will remain unchanged. The server recalculates the idempotency codes for each level of data as shown in Table 2 below.
[0171] Table 2
[0172] Card1' Idempotency code B1' Card2 Idempotency coding B2 Card3 Idempotency coding B3 Block1' Idempotency coding C1' Block2 Idempotency coding C2 Block 3 Idempotency coding C3
[0173] The server performs a consistency comparison of the idempotency codes in Tables 1 and 2. Based on the comparison results, it can determine that Card2, Card3, Block2, and Block3 level data exist in the client's local cache. Therefore, the server can delete these data from the original returned data and add idempotency codes for each level of data to the original returned data to obtain the target returned data. The hierarchical structure of the target returned data is as follows: Figure 10 As shown.
[0174] By comparison Figure 9and Figure 10 It can be observed that for hierarchical data that has not changed, the server does not retransmit it, thereby avoiding the transmission of duplicate data and saving network traffic caused by multiple transmissions of duplicate data.
[0175] Furthermore, the client received Figure 10 After the target returned the data as shown in the example, it can be used to check the local cache as shown in Table 1. Figure 10 The target returned data in the example is populated to obtain Figure 10 The example shows the original returned data. Simultaneously, the client updates its local cache; the updated local cache is shown in Table 2 above.
[0176] Figure 10 The method described above uses client-side caching and server-side idempotency checks at the granularity of individual hierarchical data to ensure that multiple retrieval operations of the same client for the same level of data are executed only once, thus guaranteeing idempotency. This avoids transmitting duplicate data and saves network traffic caused by transmitting duplicate data multiple times.
[0177] Figure 11 This is a block diagram illustrating an embodiment of a hierarchical data transmission device provided in this application. (See diagram below.) Figure 11 As shown, the device includes:
[0178] Request receiving module 1101 is used to receive data acquisition requests from clients;
[0179] Idempotent coding module 1102 is used to determine the original returned data and to determine the idempotency coding of each level of data in the original returned data;
[0180] The request parsing module 1103 is used to parse at least one first target idempotency code from the data acquisition request when it is determined that the data acquisition request needs to ensure idempotency, wherein each first target idempotency code corresponds to a cached data in the client's local cache.
[0181] Idempotency verification module 1104 is used to perform idempotency verification on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data;
[0182] The data processing module 1105 is used to process the original returned data according to the idempotency check result to obtain target returned data, and to send the target returned data to the client, wherein the target returned data includes at least the idempotency encoding of each level of data.
[0183] Optionally, the data processing module 1105 is further configured to:
[0184] If it is determined that the data acquisition request does not need to guarantee idempotency, the idempotency encoding of each level of data in the original returned data is filled into the original returned data to obtain the target returned data, and the target returned data is sent to the client.
[0185] Optionally, the device further includes:
[0186] The judgment module is used to parse the data acquisition request after receiving the data acquisition request from the client;
[0187] If an idempotent encoded field is parsed from the data acquisition request, it is determined that the data acquisition request needs to guarantee idempotency; if the idempotent encoded field is not parsed from the data acquisition request, it is determined that the data acquisition request does not need to guarantee idempotency.
[0188] Optionally, the idempotency verification module 1104 is specifically used for:
[0189] For each level of data in the original returned data, determine whether there exists a first target idempotent code that is consistent with the idempotent code of the level data;
[0190] The data processing module 1105 includes:
[0191] The first processing unit is configured to, when the idempotency check result indicates the existence of a first target idempotency code that is consistent with the idempotency code of the hierarchical data, add the idempotency code of the hierarchical data to the original returned data and delete the hierarchical data from the original returned data to obtain the target returned data;
[0192] The second processing unit is used to add the idempotency code of the hierarchical data to the original returned data when the idempotency check result indicates that there is no first target idempotency code that is consistent with the idempotency code of the hierarchical data, so as to obtain the target returned data.
[0193] Optionally, the idempotent encoding module 1102 is specifically used for:
[0194] For each level of data in the original returned data, a message digest of the data at that level is generated using a set algorithm;
[0195] The information digest is determined as the idempotent encoding of the hierarchical data.
[0196] Figure 12 A block diagram illustrating another embodiment of a hierarchical data transmission apparatus provided in this application. (See diagram below.) Figure 12 As shown, the device includes:
[0197] The request sending module 1201 is configured to send a data acquisition request to the server, so that the server receives the data acquisition request, determines the original returned data, and determines the idempotency encoding of each level of data in the original returned data; if it is determined that the data acquisition request needs to ensure idempotency, at least one first target idempotency encoding is parsed from the data acquisition request, wherein each first target idempotency encoding corresponds to a cached data in the client's local cache; the original returned data is idempotently verified based on the at least one first target idempotency encoding and the idempotency encoding of each level of data in the original returned data; the original returned data is processed accordingly based on the idempotency verification result to obtain target returned data, and the target returned data is sent to the client;
[0198] The data receiving module 1202 is used to receive the target returned data from the server.
[0199] The data parsing module 1203 is used to parse a second target idempotency code that meets set conditions from the target returned data, wherein the set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target returned data;
[0200] The data filling module 1204 is used to obtain target cache data corresponding to the second target idempotency code from the local cache, and fill the target cache data into the target return data as hierarchical data corresponding to the second target idempotency code to obtain the original return data.
[0201] Optionally, the device further includes:
[0202] The data storage module is used to parse the third target idempotency code that does not meet the set conditions and the hierarchical data corresponding to the third target idempotency code from the target returned data;
[0203] The third target idempotency code and its corresponding hierarchical data are stored in the local cache.
[0204] Optionally, the request sending module 1201 includes:
[0205] If it is determined that the local cache is not empty, an idempotency encoding field is added to the data retrieval request, and the idempotency encoding in the local cache is used as the value of the idempotency encoding field;
[0206] A data retrieval request with the idempotency encoding field added is sent to the server, so that the server, after parsing the idempotency encoding field from the received data retrieval request, determines that the received data retrieval request needs to guarantee idempotency.
[0207] Optionally, the device further includes:
[0208] The cleanup module is used to set a lifetime for each idempotent code and its corresponding hierarchical data in the local cache, so that when the lifetime is reached, the corresponding idempotent code and its corresponding hierarchical data will be deleted from the local cache.
[0209] like Figure 13 As shown in the figure, this application provides an electronic device, including a processor 1311, a communication interface 1312, a memory 1313, and a communication bus 1314, wherein the processor 1311, the communication interface 1312, and the memory 1313 communicate with each other through the communication bus 1314.
[0210] Memory 1313 is used to store computer programs;
[0211] In one embodiment of this application, the processor 1311, when executing a program stored in the memory 1313, implements the hierarchical data transmission method provided in any of the foregoing method embodiments, including:
[0212] Receive a data acquisition request from the client, determine the original returned data, and determine the idempotency encoding of each level of data in the original returned data;
[0213] If it is determined that the data acquisition request needs to be idempotent, the following steps are performed:
[0214] At least one first target idempotency code is parsed from the data acquisition request, wherein each first target idempotency code corresponds to a cached data in the client's local cache;
[0215] Idempotency verification is performed on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data;
[0216] The original returned data is processed according to the idempotency check result to obtain the target returned data, which is then sent to the client. The target returned data includes at least the idempotency encoding of each level of data.
[0217] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the hierarchical data transmission method provided in any of the foregoing method embodiments.
[0218] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0219] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0220] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0221] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for transmitting hierarchical data, characterized in that, The method includes: Receive a data acquisition request from the client, determine the original returned data, and determine the idempotency encoding of each level of data in the original returned data; If it is determined that the data acquisition request needs to be idempotent, the following steps are performed: At least one first target idempotency code is parsed from the data acquisition request, wherein each first target idempotency code corresponds to a cached data in the client's local cache; Idempotency verification is performed on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data; The original returned data is processed according to the idempotency check result to obtain the target returned data, and the target returned data is sent to the client. The target returned data includes at least the idempotency encoding of each level of data. The process of processing the original returned data according to the idempotency check result to obtain the target returned data includes: when the idempotency check result indicates the existence of a first target idempotency code that is consistent with the idempotency code of the hierarchical data, adding the idempotency code of the hierarchical data to the original returned data and deleting the hierarchical data from the original returned data to obtain the target returned data; If the idempotency check result indicates that there is no first target idempotency code that is consistent with the idempotency code of the hierarchical data, the idempotency code of the hierarchical data is added to the original returned data to obtain the target returned data.
2. The method according to claim 1, characterized in that, The method further includes: If it is determined that the data acquisition request does not need to guarantee idempotency, the idempotency encoding of each level of data in the original returned data is filled into the original returned data to obtain the target returned data, and the target returned data is sent to the client.
3. The method according to claim 1 or 2, characterized in that, The method further includes: After receiving the data acquisition request from the client, the data acquisition request is parsed; If an idempotent encoded field is parsed from the data acquisition request, it is determined that the data acquisition request needs to guarantee idempotency; if the idempotent encoded field is not parsed from the data acquisition request, it is determined that the data acquisition request does not need to guarantee idempotency.
4. The method according to claim 1, characterized in that, The step of performing idempotency verification on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data includes: For each level of data in the original returned data, determine whether there exists a first target idempotent code that is consistent with the idempotent code of the level data.
5. The method according to claim 1, characterized in that, Determining the idempotency encoding of each level of data in the original returned data includes: For each level of data in the original returned data, a message digest of the data at that level is generated using a set algorithm; The information digest is determined as the idempotent encoding of the hierarchical data.
6. A method for transmitting hierarchical data, characterized in that, The method includes: A data retrieval request is sent to the server, enabling the server to receive the request, determine the original returned data, and determine the idempotency encoding of each level of data in the original returned data. If it is determined that the data retrieval request needs to guarantee idempotency, at least one first target idempotency encoding is parsed from the data retrieval request, wherein each first target idempotency encoding corresponds to a cached data in the client's local cache. Based on the at least one first target idempotency encoding and the idempotency encoding of each level of data in the original returned data, an idempotency check is performed on the original returned data. Based on the idempotency check result, the original returned data is processed accordingly to obtain the target idempotency encoding. The system returns target data to the client. The process involves processing the original return data according to the idempotency check result to obtain the target return data. This includes: if the idempotency check result indicates the existence of a first target idempotency code consistent with the idempotency code of the hierarchical data, adding the idempotency code of the hierarchical data to the original return data and deleting the hierarchical data from the original return data; and if the idempotency check result indicates the absence of a first target idempotency code consistent with the idempotency code of the hierarchical data, adding the idempotency code of the hierarchical data to the original return data to obtain the target return data. The system receives the target return data from the server and parses out the second target idempotency code that meets the set conditions from the target return data. The set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target return data. Retrieve the target cache data corresponding to the second target idempotency encoding from the local cache, and fill the target return data with the target cache data as the hierarchical data corresponding to the second target idempotency encoding to obtain the original return data.
7. The method according to claim 6, characterized in that, The method further includes: Parse the third target idempotency code that does not meet the set conditions and the corresponding hierarchical data from the target returned data; The third target idempotency code and its corresponding hierarchical data are stored in the local cache.
8. The method according to claim 6 or 7, characterized in that, Sending a data retrieval request to the server includes: If it is determined that the local cache is not empty, an idempotency encoding field is added to the data retrieval request, and the idempotency encoding in the local cache is used as the value of the idempotency encoding field; A data retrieval request with the idempotency encoding field added is sent to the server, so that the server, after parsing the idempotency encoding field from the received data retrieval request, determines that the received data retrieval request needs to guarantee idempotency.
9. The method according to claim 6 or 7, characterized in that, The method further includes: A lifetime is set for each idempotent code and its corresponding hierarchical data in the local cache, so that when the lifetime is reached, the corresponding idempotent code and its corresponding hierarchical data are deleted from the local cache.
10. A device for transmitting hierarchical data, characterized in that, The device includes: The request receiving module is used to receive data retrieval requests from clients; An idempotent coding module is used to determine the original returned data and to determine the idempotency coding of each level of data in the original returned data; The request parsing module is used to parse at least one first target idempotency code from the data acquisition request when it is determined that the data acquisition request needs to ensure idempotency, wherein each first target idempotency code corresponds to a cached data in the client's local cache; An idempotency verification module is used to perform idempotency verification on the original returned data based on the at least one first target idempotency code and the idempotency code of each level of data in the original returned data; The data processing module is used to process the original returned data according to the idempotency check result to obtain the target returned data, and send the target returned data to the client, wherein the target returned data includes at least the idempotency encoding of each level of data; The data processing module includes: The first processing unit is configured to, when the idempotency check result indicates the existence of a first target idempotency code that is consistent with the idempotency code of the hierarchical data, add the idempotency code of the hierarchical data to the original returned data and delete the hierarchical data from the original returned data to obtain the target returned data; The second processing unit is used to add the idempotency code of the hierarchical data to the original returned data when the idempotency check result indicates that there is no first target idempotency code that is consistent with the idempotency code of the hierarchical data, so as to obtain the target returned data.
11. A device for transmitting hierarchical data, characterized in that, The device includes: A request sending module is configured to send a data retrieval request to the server, enabling the server to receive the request, determine the original returned data, and determine the idempotency encoding of each level of data in the original returned data. If the data retrieval request needs to guarantee idempotency, at least one first target idempotency encoding is parsed from the request, wherein each first target idempotency encoding corresponds to a cached data in the client's local cache. Based on the at least one first target idempotency encoding and the idempotency encoding of each level of data in the original returned data, the original returned data is subjected to idempotency verification. Based on the idempotency verification result, the original returned data is processed accordingly. The process involves processing the original return data to obtain the target return data, and then sending the target return data to the client. Specifically, processing the original return data according to the idempotency check result to obtain the target return data includes: if the idempotency check result indicates the existence of a first target idempotency code consistent with the idempotency code of the hierarchical data, adding the idempotency code of the hierarchical data to the original return data and deleting the hierarchical data from the original return data to obtain the target return data; if the idempotency check result indicates the absence of a first target idempotency code consistent with the idempotency code of the hierarchical data, adding the idempotency code of the hierarchical data to the original return data to obtain the target return data. A data receiving module is used to receive the target returned data from the server. The data parsing module is used to parse a second target idempotency code that meets set conditions from the target returned data, wherein the set conditions include: there is no hierarchical data corresponding to the second target idempotency code in the target returned data; The data filling module is used to obtain target cache data corresponding to the second target idempotency code from the local cache, and fill the target returned data with the target cache data as hierarchical data corresponding to the second target idempotency code to obtain the original returned data.
12. An electronic device, characterized in that, include: A processor and a memory, the processor being configured to execute a transmission program for hierarchical data stored in the memory, to implement the method for transmitting hierarchical data according to any one of claims 1 to 9.
13. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the method for transmitting hierarchical data as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Multilevel cache data processing method and device, storage medium and server
CN109614347A
Employee attribute information verification method, device and terminal device
CN110471912A