Data updating method and device, computer equipment and storage medium
By analyzing client requests in the server-side data update method, determining the target cache space, calculating matching similarity and obtaining response data, the problems of poor real-time data and low acquisition efficiency in the prior art are solved, and efficient data response is achieved.
Patent Information
- Application Number
- CN202311163084.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-08
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, when the client obtains the latest data on the server in real time, there are problems such as poor real-time data and low acquisition efficiency, especially in high concurrency scenarios, where data updates are difficult to deal with frequently.
Through the data update method executed on the server, the client receives the data update request, parses the request type and field information, determines the target cache space, calculates the matching similarity between the data update request and the target cache space, and when the similarity is greater than the preset threshold, the response data is obtained from the target cache space and adds the server cache identifier, and generates a data response request and sends it to the client.
Improve cache utilization, avoid repeated rendering by clients, effectively utilize cache, reduce server computing and network bandwidth consumption, and improve data response efficiency.
Smart Images

Figure CN119597763A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data acquisition, and in particular to a data updating method, device, computer equipment and storage medium. Background Art
[0002] With the development of technology and the requirements of customers for data acquisition, we often encounter scenarios where the client needs to obtain the latest data from the server in real time. The solutions for obtaining server data in real time include short polling, long polling, and long connection (WebSocket). However, short polling has the disadvantages of too many useless requests and poor data real-time performance; long polling requires continuous sending of requests to query data, which is difficult to handle frequent data updates and is not suitable for high-concurrency scenarios; long connection is more complex to implement and has a higher cost. Therefore, it is necessary to propose a data update solution with high data acquisition efficiency and strong real-time performance. Summary of the invention
[0003] The embodiments of the present application provide a data updating method, apparatus, computer equipment and storage medium to solve the technical problems of poor real-time performance of data updating and low efficiency of data acquisition.
[0004] On the one hand, the present application provides a data updating method, the data updating method comprising the following steps performed by a server:
[0005] Receive a data update request sent by a client, and parse the request type and field information from the data update request;
[0006] Based on the request type, determining a target cache space from a plurality of local request cache spaces, wherein each of the request cache spaces includes a plurality of request descriptions;
[0007] Determining a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space;
[0008] When the matching similarity is greater than a preset similarity threshold, obtaining response data of the data update request from the target cache space, and adding a server cache identifier to the response data;
[0009] A data response request for the data update request is generated according to the server cache identifier and the response data, and the data response request is sent to the client.
[0010] In a second aspect, the present application provides a data updating method, the data updating method comprising the following steps performed by a client:
[0011] Send data update request response to the server;
[0012] If a data response request based on the data update request sent by the server is received, determining whether the data response request response includes a server cache identifier;
[0013] If the data response request includes a server cache identifier, the rendering data corresponding to the server cache identifier is obtained from the local cache space.
[0014] In a third aspect, the present application further provides a data updating device, the data updating device comprising:
[0015] A parsing module, used to receive a data update request sent by a client, and parse the request type and field information from the data update request;
[0016] A first determination module, configured to determine a target cache space from a plurality of local request cache spaces based on the request type, wherein each of the request cache spaces includes a plurality of request descriptions;
[0017] A second determination module, configured to determine a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space;
[0018] A first acquisition module, configured to acquire the response data of the data update request from the target cache space when the matching similarity is greater than a preset similarity threshold, and to add a server cache identifier to the response data;
[0019] The first sending module is used to generate a data response request for the data update request according to the server cache identifier and the response data, and send the data response request to the client.
[0020] In a fourth aspect, the present application further provides a computer device, the computer device comprising:
[0021] one or more processors;
[0022] Memory; and
[0023] One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to implement the steps in the data updating method described in any one of the first aspect or the second aspect.
[0024] In a fifth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is loaded by a processor to execute the steps in the data updating method described in any one of the first aspect or the second aspect.
[0025] The present application obtains and receives a data update request, parses the request type and field information; determines a target cache space from multiple local request cache spaces, and determines the matching similarity between the data update request and the target cache space based on the field information and multiple request descriptions in the target cache space; obtains response data of the data update request from the target cache space when the matching similarity is greater than a preset similarity threshold, and adds a server cache identifier to the response data; generates a data response request for the data update request based on the server cache identifier and the response data, and sends the data response request to the client, thereby improving cache utilization under limited cache space, avoiding repeated rendering of the client, and effectively utilizing the cache, reducing the server's computing workload and network bandwidth consumption, and improving data response efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 is a scenario diagram of a data updating device provided in an embodiment of the present application;
[0028] Figure 2 It is a flowchart of an embodiment of the data updating method provided in the embodiments of the present application;
[0029] Figure 3 is a flowchart of another embodiment of the data updating method provided in the embodiments of the present application;
[0030] Figure 4 is an interactive flow chart of the data updating method provided in the embodiment of the present application;
[0031] Figure 5 is a schematic diagram of the structure of an embodiment of a data updating device provided in an embodiment of the present application;
[0032] Figure 6 It is a schematic diagram of the structure of an embodiment of a computer device provided in the embodiments of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0034] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0035] In this application, the word "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any technician in the field to implement and use the present application. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present application can be implemented without using these specific details. In other instances, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present application with unnecessary details. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.
[0036] It should be noted that since the method of the embodiment of the present application is executed in a computer device, the processing objects of each computer device exist in the form of data or information. For example, the time described in this article is actually time information, which is used to characterize the information of time. It can be understood that if the size, quantity, position, etc. are mentioned in the subsequent embodiments, they all exist in the corresponding data form to facilitate the computer device to process, and the details will not be repeated here.
[0037] The embodiments of the present application provide a data updating method, apparatus, computer device and storage medium, which are described in detail below.
[0038] See also Figure 1 , Figure 1 Schematic diagram of a scenario of a data updating device provided in an embodiment of the present application. The data updating device may include a computer device. The computer device provided in an embodiment of the present application may include: a server 100 and a client 200, such as Figure 1The computer device in the application, the server 100 is connected to the client 200 in communication, so that the server 100 can interact with the client 200 for data, ensuring that the server 100 can send a data response request to the client 200 after receiving the data update request sent by the client 200. The server 100 in the application may include a hardware server or a cloud server, etc., and the application does not make specific restrictions on it. The client 200 in the application may include a mobile phone, a tablet, a laptop or a desktop computer, etc., and the application does not make specific restrictions on it.
[0039] like Figure 2 As shown in FIG. 1 , a flow chart of an embodiment of a data updating method in an embodiment of the present application is shown. The data updating method may include the following steps 101 to 105 executed by the server, which are as follows:
[0040] 101. Receive a data update request sent by a client, and parse the data update request to obtain a request type and field information.
[0041] The data update request is a request sent by the client to the server for updating the client's data. The request type can be real-time data update, offline data update, or instant messaging data update.
[0042] Specifically, in the client application, an EventSource object is used to establish a link with an HTTP streaming server. The EventSource object is a native API of the browser and is used to enable the server to push events to the client. Compared with the conventional polling method, the use of the EventSource object allows for more efficient and low-latency data transmission.
[0043] In a specific implementation, the data update request is a data update request in SSE format; parsing the request type and field information from the data update request in step 101 may include the following step 101A, which is as follows:
[0044] 101A. Parse the data update request according to the SSE format to obtain the request type and the field information.
[0045] The SSE format data request is data sent via (Server-Send Events, message push).
[0046] Specifically, you can build an SSE (Server-Send Events, message push) server application. For example, you can use Node.js to build an SSE application, where Node.js is a JavaScript runtime environment that supports the execution of JavaScript code, that is, Node.js is a JavaScript runtime (Runtime). Then use the express or http module to create an HTTP stream server, set the response header, such as Content-Type: text / event-stream, and enable a long connection, such as Connection: keep-alive; use the res.write() and res.flush() methods to write the data update request to the response, so that the data update request is a data update request in the SSE format, download and install sse-express, which is used to format and process the data update request issued by the SSE client, that is, the real-time data that is pushed to the client, parse the SSE format data update request sent by the server according to the SSE format, and output the request type and field information. It can be understood that in this embodiment, by setting the data update request to a data update request in SSE format, since SSE is a one-way channel, only the server can send information to the browser. Compared with long connections, SSE does not require a complicated handshake process and communication protocol, and can run directly on the HTTP connection, which is more convenient and faster, and improves the efficiency of parsing data update requests.
[0047] 102. Based on the request type, determine a target cache space from multiple local request cache spaces, wherein each of the request cache spaces includes multiple request descriptions.
[0048] Among them, the request description is used to characterize the field information of the request. The local server has multiple request cache spaces for storing requests sent by the client. Each request cache space can set a cache expiration time or cache space, and each request cache space includes multiple request descriptions. The received requests can be pre-stored through the request cache space. The target cache space is a request cache space among the multiple local request cache spaces that best matches the request type, and is used to cache the request cache space for data update requests.
[0049] Specifically, the same number of request cache spaces can be set in advance according to the number of request types. Taking the three request types in step 101 as an example, three corresponding request cache spaces are set. For example, the cache space of each request cache space is different. The total cache space of the local request cache space is called S1. For real-time library table information reqType='real', the cache space size is set to N1, which is called request cache space S1-1. For offline library table information reqType='offline', the cache space size is set to N2, which is called request cache space S1-2. For customer service consultation information reqType='news', the cache space size is set to N3, which is called request cache space S1-3. After pre-setting cache spaces of different request types, the request type consistent with the set request type can be found from multiple request cache spaces on the server side according to the request type as the target request type, and then the request cache space corresponding to the target request type is used as the target cache space. For example, if the request type is represented by reqType='news', the target cache space is S1-3.
[0050] 103. Determine a matching similarity between the data update request and the target cache space based on the field information and multiple request descriptions in the target cache space.
[0051] The matching similarity refers to the similarity between the data update request and the request description in the target cache space.
[0052] Specifically, since both the field information and the request description are text information, a text similarity calculation method can be used to calculate the similarity between the field information and multiple request descriptions in the target cache space to obtain multiple similarities, where the text similarity calculation method can be Euclidean distance, Mahalanobis distance, cosine distance, etc., and then the maximum similarity is selected from the multiple similarities between the field information and each request description as the target similarity.
[0053] In a specific implementation, determining the matching similarity between the data update request and the target cache space based on the field information and the multiple request descriptions in the target cache space in step 103 may include the following steps 103A-103B, which are specifically as follows:
[0054] 103A. Filtering multiple candidate request descriptions from the target cache space based on the field information;
[0055] 103B. Determine the similarity between the field information and the multiple candidate request descriptions to obtain multiple similarities, and determine the maximum similarity among the multiple similarities as the matching similarity.
[0056] The candidate request description is a request description whose field information hit rate of the request description in the target cache space meets a preset threshold, wherein the preset threshold may be 85%, 90% or 92%, etc.
[0057] Specifically, the Transformer architecture technology can be used to parse the field information and the request description, and then the text similarity algorithm is used to calculate the similarity between the field information and each candidate request description, to obtain a set of similarities, and the maximum similarity is used as the matching similarity. It can be understood that in this embodiment, by screening the candidate similarities, the number of similarity calculations is reduced while ensuring the accuracy of the matching similarity calculation, thereby greatly improving the calculation efficiency of the matching similarity.
[0058] 104. When the matching similarity is greater than a preset similarity threshold, obtain response data of the data update request from the target cache space, and add a server cache identifier to the response data.
[0059] The preset similarity threshold is a preset threshold value for determining whether a data update request appears in a target cache space, that is, whether the cache space is hit. The preset similarity threshold may be 80%, 90%, or 95%, etc. The response data refers to the response data of the data update request obtained from the target cache space.
[0060] Specifically, if the matching similarity is greater than a preset similarity threshold, it is determined that the data update request appears in the target cache space, that is, it hits the target cache space, that is, before, the target cache space is accessed, then a server cache identifier is added to the response data of the data update request. Therefore, the server does not need to perform unnecessary calculations, thereby improving the response efficiency of the data update request. At the same time, a server cache identifier is added to the response data of the data update request to identify that the field information of the response data of the data update request appears more than 1 times in the target cache space, so that the hit status of the data update request can be determined directly based on the server cache identifier in the future.
[0061] It should be noted that in order to improve the accuracy of data update requests that hit the cache space, a similarity threshold can be set according to the request type in the data update request. Continuing with the three request types in step 101 as an example, the similarity threshold is A. For real-time library table information reqType='real', the similarity threshold is set to A=80% (if the real-time requirement is higher, A can be set smaller), for offline library table information reqType='offline', the similarity threshold is set to A=90% (if the update frequency of offline data is lower, A can be set larger), and for customer service consultation information reqType='news', the similarity threshold is set to A=95% (if the update frequency of customer service consultation information is lower, A can be set larger).
[0062] It is worth noting that if the matching similarity is greater than a preset similarity threshold, the field information of the data update request is moved to the head of the target cache space to improve the accuracy of calculating the cache space hit rate.
[0063] In a specific implementation, after determining the similarity between the field information and the multiple candidate request descriptions in step 103B, obtaining multiple similarities, and determining the maximum similarity among the multiple similarities as the matching similarity, the following steps 103C to 103D may also be included, specifically as follows:
[0064] 103C. When the matching similarity is less than or equal to the preset similarity threshold, taking the candidate request description corresponding to the maximum similarity among multiple similarities as the target request description;
[0065] 103D. Insert the target request description and request type into the target cache space in the form of a key-value pair.
[0066] The target request description is the candidate request description with the greatest similarity to the field information in the target cache space. The key-value pair can be in the form of a Map key-value pair, i.e., Map<key,value> , which can remember the original insertion order of the keys. Any value (object or basic type) can be used as a key or a value. In this embodiment, the target request description can be used as a key and the request type can be used as a value.
[0067] Specifically, if the matching similarity is less than or equal to the preset similarity threshold, it is determined that the data update request does not appear in the target cache space, that is, the target cache space is not hit, that is, the target cache space has not been accessed before, and the target request description and request type are inserted into the target cache space in the format of a key-value pair. As a preferred embodiment of this embodiment, the target request description and request type can be inserted into the header of the target cache space in the format of a key-value pair to characterize that the data update request is the latest or most recent request. By inserting the target request description and request type into the header of the target cache space in the format of a key-value pair, the target cache space can be continued to be used in the future to improve the accuracy of the calculation of the cache space hit rate, so that the server does not need to perform unnecessary calculations, thereby further improving the response efficiency of data update requests.
[0068] It is worth noting that when the matching similarity is less than or equal to the preset similarity threshold, in order to respond to the data update request, response data can be obtained by responding to the data update request, a data response request for the data update request can be generated based on the response data, and the data response request can be sent to the client.
[0069] 105. Generate a data response request for the data update request according to the server cache identifier and the response data, and send the data response request to the client.
[0070] Specifically, a data response request for the data update request is generated based on the server cache identifier and response data, and the data response request is sent to the client. If the data update request hits a request description in the target cache space, the response data of the data update request is directly obtained from the target cache space, and the server does not need to perform unnecessary calculations, thereby improving response efficiency.
[0071] In a specific implementation manner, before obtaining the response data of the data update request from the target cache space in step 105 and obtaining the target update data, the following steps 106 to 107 may also be included, which are specifically as follows:
[0072] 106. Setting a cache expiration time according to the request type;
[0073] 107. If the current time exceeds the cache expiration time, clear the data in the target cache space.
[0074] The cache expiration time refers to the validity period of the request cache space in the server for data update requests.
[0075] Specifically, the cache expiration time T of the request cache space in the server is set according to the request type. Taking the three request types in step 101 as an example, three corresponding cache expiration times are set. For real-time library table information reqType='real', the cache expiration time T=1 hour is set (if the real-time requirement is higher, T can be set to a smaller value), for offline library table information reqType='offline', the cache expiration time T=1 day is set (if the update frequency of offline data is lower, T can be set to a larger value), and for customer service consultation information reqType='news', the cache expiration time T=7 days is set (if the update frequency of customer service consultation information is lower, T can be set to a larger value); the cache expiration time can be set according to the request type's requirements for data real-time performance. If the current time exceeds the cache expiration time, the data in the target cache space is cleared to avoid interference from invalid response data and improve data update efficiency.
[0076] It is worth noting that in order to maintain the real-time and consistency of client and server data, after setting the cache expiration time of the server, you also need to set the cache expiration time of the client, and the cache expiration time of the client should be consistent with the cache expiration time of the server.
[0077] like Figure 3 As shown, it is a flowchart of an embodiment of a data updating method in an embodiment of the present application. The data updating method may include the following steps 201 to 203 executed by the client, which are as follows:
[0078] 201. Send a data update request response to the server.
[0079] The data update request response is a request response to a data update request sent by the client to the server.
[0080] Specifically, you can create an EventSource object on the client, and then send an HTTP request to the specified server URL. At this time, the server needs to support the EventStream format, that is, the Content-Type is text / event-stream, and the client sends a data update request response to the server.
[0081] 202. If a data response request based on the data update request sent by the server is received, determine whether the data response request response includes a server cache identifier.
[0082] Specifically, when the client receives the data response request sent by the server, it directly determines whether the data in the data response request contains a server cache identifier to determine whether the data in the data response request is rendered.
[0083] 203. If the data response request includes a server cache identifier, obtain rendering data corresponding to the server cache identifier from the local cache space.
[0084] Specifically, when the data response request contains a server cache identifier, it indicates that the data in the data response request has been rendered. At this time, the rendering data corresponding to the server cache identifier is directly obtained from the local cache space, that is, the client's cache space, that is, the rendering data of the data response request is directly obtained from the client's cache space, so that the client does not need to perform unnecessary rendering operations, thereby improving web page performance and user experience.
[0085] In an example, the client data can be cached by setting the client cache expiration time and using the LRU algorithm to optimize the client cache data. The specific steps are as follows:
[0086] T1: Set the client cache expiration time to T, which is consistent with the server cache expiration time to maintain the real-time and consistency of client and server data;
[0087] T2: Use the LRU algorithm to cache client data: Set the client cache space size to N, called the response cache space S2, and respond to the data update request through the rendering result of the data response request. If the data response request contains a server cache identifier, it is used as the target cache request.
[0088] In a specific implementation, the following steps 204 to 205 may also be included, as follows:
[0089] 204. If the data response request does not include a server cache identifier, obtain a rendering result in the data response request;
[0090] 205. Insert the request description of the data response request and the rendering result into the local cache space in the form of key-value pairs.
[0091] Specifically, when the data response request does not contain the server cache identifier, it indicates that the rendering data in the data response request has never appeared in the client's cache space. Taking the target cache request in step 203 as an example, it indicates that the request description of the target cache request has never appeared in the response cache space. The request description of the data response request and the rendering result are inserted into the local cache space in the form of a key-value pair. As a preferred embodiment of this embodiment, the request description of the data response request and the rendering result are inserted into the header of the local cache space in the form of a key-value pair, so that the data response request can be continued to be used subsequently, thereby improving the accuracy of the calculation of the cache space hit rate, so that the client does not need to perform unnecessary rendering operations, thereby improving the web page performance and further improving the response efficiency of data update requests.
[0092] It is worth noting that when the data response request does not include the server cache identifier, in order to respond to the data response request, the rendering data can be obtained by responding to the data response request, a data update request for the data response request can be generated based on the rendering data, and the data update request can be sent to the server.
[0093] like Figure 4 As shown, it is an interactive flow chart of the data updating method, and the method may include the following steps 301 to 307, which are as follows:
[0094] 301. The client sends a data update request to the server;
[0095] 302. The server receives a data update request and parses the request type and field information from the data update request;
[0096] 303. The server determines a target cache space from a plurality of local request cache spaces based on the request type, wherein each of the request cache spaces includes a plurality of request descriptions;
[0097] 304. The server determines the matching similarity between the data update request and the target cache space based on the field information and multiple request descriptions in the target cache space; when the matching similarity is greater than a preset similarity threshold, the server obtains the response data of the data update request from the target cache space, and adds a server cache identifier to the response data;
[0098] 305. The server generates a data response request for the data update request according to the server cache identifier and the response data, and sends the data response request to the client;
[0099] 306. If the client receives a data response request based on the data update request sent by the server, it determines whether the data response request response includes a server cache identifier;
[0100] 307. If the data response request includes a server cache identifier, the client obtains rendering data corresponding to the server cache identifier from the local cache space.
[0101] The specific implementation of the above steps can be referred to Figures 2 to 3 The steps of the illustrated embodiment will not be described in detail in the embodiment of the present application.
[0102] In order to better implement the data updating method in the embodiment of the present application, based on the data updating method, the embodiment of the present application also provides a data updating device, such as Figure 5As shown, the data updating device 400 includes a server, and the server includes:
[0103] The parsing module 401 is used to receive a data update request sent by a client, and parse the request type and field information from the data update request;
[0104] A first determination module 402 is used to determine a target cache space from a plurality of local request cache spaces based on a request type, wherein each request cache space includes a plurality of request descriptions;
[0105] A second determination module 403, configured to determine a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space;
[0106] A first acquisition module 404 is used to acquire the response data of the data update request from the target cache space when the matching similarity is greater than a preset similarity threshold, and to add a server cache identifier to the response data;
[0107] The first sending module 405 is configured to generate a data response request for the data update request according to the server cache identifier and the response data, and send the data response request to the client.
[0108] In the embodiment of the present application, the data update request is a data update request in SSE format; the parsing module 401 is specifically used for:
[0109] The data update request is parsed according to the SSE format to obtain the request type and the field information.
[0110] In the embodiment of the present application, the second determining module 403 is specifically used for:
[0111] Based on the field information, screening out a plurality of candidate request descriptions from the target cache space;
[0112] The similarity between the field information and the multiple candidate request descriptions is determined to obtain multiple similarities, and the maximum similarity among the multiple similarities is determined as the matching similarity.
[0113] In the embodiment of the present application, the data updating device 400 further includes:
[0114] A third determination module is used to use the candidate request description corresponding to the maximum similarity among multiple similarities as the target request description when the matching similarity is less than or equal to the preset similarity threshold;
[0115] The data insertion module is used to insert the target request description and request type into the target cache space in the form of a key-value pair.
[0116] In the embodiment of the present application, the data updating device further includes:
[0117] A setting module, used to set a cache expiration time according to the request type;
[0118] The clearing module is used to clear the data in the target cache space if the current time exceeds the cache expiration time.
[0119] The embodiment of the present application further provides a data updating device, the data updating device comprising a client, the client comprising:
[0120] The second sending module is used to send a data response request to the server;
[0121] A judgment module, configured to judge whether a data response request based on the data update request sent by the server includes a server cache identifier if a data response request based on the data update request is received;
[0122] The second acquisition module is configured to acquire rendering data corresponding to the server cache identifier from the local cache space if the data response request includes the server cache identifier.
[0123] In the embodiment of the present application, the data updating device further includes:
[0124] A third acquisition module, configured to acquire a rendering result in the data response request if the data response request does not include a server cache identifier;
[0125] The result insertion module is used for inserting the request description of the data response request and the rendering result into the local cache space in the form of key-value pairs in response to the data request.
[0126] The embodiment of the present application further provides a computer device, which integrates any one of the data updating devices provided in the embodiment of the present application, and the computer device includes:
[0127] one or more processors;
[0128] Memory; and
[0129] One or more applications, wherein the one or more applications are stored in the memory and are configured so that the processor executes the steps of the data updating method described in any of the above data updating method embodiments.
[0130] The present application also provides a computer device that integrates any data updating device provided in the present application. Figure 6 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:
[0131] The computer device may include one or more processing core processors 701, one or more computer readable storage media memories 702, a power supply 703, an input unit 704 and other components. Those skilled in the art will appreciate that Figure 6 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0132] The processor 701 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 702 and calling data stored in the memory 702, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701.
[0133] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
[0134] The computer device also includes a power supply 703 for supplying power to various components. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 703 can also include any combination of one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, etc.
[0135] The computer device may further include an input unit 704, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0136] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 701 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 will run the application programs stored in the memory 702, thereby realizing various functions, as follows:
[0137] Receive a data update request sent by a client, and parse the request type and field information from the data update request;
[0138] Based on the request type, determining a target cache space from a plurality of local request cache spaces, wherein each of the request cache spaces includes a plurality of request descriptions;
[0139] Determining a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space;
[0140] When the matching similarity is greater than a preset similarity threshold, obtaining response data of the data update request from the target cache space, and adding a server cache identifier to the response data;
[0141] A data response request for the data update request is generated according to the server cache identifier and the response data, and the data response request is sent to the client.
[0142] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0143] To this end, an embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any data update method provided in the embodiment of the present application. For example, the computer program can be loaded by a processor to execute the following steps:
[0144] Receive a data update request sent by a client, and parse the request type and field information from the data update request;
[0145] Based on the request type, determining a target cache space from a plurality of local request cache spaces, wherein each of the request cache spaces includes a plurality of request descriptions;
[0146] Determining a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space;
[0147] When the matching similarity is greater than a preset similarity threshold, obtaining response data of the data update request from the target cache space, and adding a server cache identifier to the response data;
[0148] A data response request for the data update request is generated according to the server cache identifier and the response data, and the data response request is sent to the client.
[0149] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.
[0150] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.
[0151] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0152] The above is a detailed introduction to a data updating method, device and storage medium provided in an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data updating method, characterized in that: Applied to the server, the data updating method includes: Receive a data update request sent by a client, and parse the request type and field information from the data update request; Based on the request type, determining a target cache space from a plurality of local request cache spaces, wherein each of the request cache spaces includes a plurality of request descriptions; Determining a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space; When the matching similarity is greater than a preset similarity threshold, obtaining response data of the data update request from the target cache space, and adding a server cache identifier to the response data; A data response request for the data update request is generated according to the server cache identifier and the response data, and the data response request is sent to the client.
2. The data updating method according to claim 1, characterized in that: The determining, based on the field information and the multiple request descriptions in the target cache space, a matching similarity between the data update request and the target cache space includes: Based on the field information, screening out a plurality of candidate request descriptions from the target cache space; The similarity between the field information and the multiple candidate request descriptions is determined to obtain multiple similarities, and the maximum similarity among the multiple similarities is determined as the matching similarity.
3. The data updating method according to claim 2, characterized in that: After determining the matching similarity between the data update request and the target cache space based on the field information and the multiple request descriptions in the target cache space, the method further includes: When the matching similarity is less than or equal to the preset similarity threshold, taking the candidate request description corresponding to the maximum similarity among multiple similarities as the target request description; The target request description and request type are inserted into the target cache space in the form of a key-value pair.
4. The data updating method according to claim 1, characterized in that: Before obtaining the response data of the data update request from the target cache space, the method further includes: Set cache expiration time according to the request type; If the current time exceeds the cache expiration time, the data corresponding to the request type in the target cache space is cleared.
5. The data updating method according to claim 1, characterized in that: The data update request is a data update request in SSE format; The step of parsing the request type and field information from the data update request includes: The data update request is parsed according to the SSE format to obtain the request type and the field information.
6. A data updating method, characterized in that: Applied to the client, the data updating method includes: Send a data update request to the server; If a data response request based on the data update request sent by the server is received, determining whether the data response request response includes a server cache identifier; If the data response request includes a server cache identifier, the rendering data corresponding to the server cache identifier is obtained from the local cache space.
7. The data updating method according to claim 1, characterized in that: Also includes: If the data response request does not include a server cache identifier, obtaining a rendering result in the data response request; Inserting the request description of the data response request and the rendering result into the local cache space in the form of key-value pairs.
8. A data updating device, characterized in that: The data updating device comprises: A parsing module, used for receiving a data update request sent by a client, and parsing the request type and field information from the data update request; A first determination module, configured to determine a target cache space from a plurality of local request cache spaces based on the request type, wherein each of the request cache spaces includes a plurality of request descriptions; A second determination module, configured to determine a matching similarity between the data update request and the target cache space based on the field information and a plurality of request descriptions in the target cache space; A first acquisition module, configured to acquire the response data of the data update request from the target cache space when the matching similarity is greater than a preset similarity threshold, and to add a server cache identifier to the response data; The first sending module is used to generate a data response request for the data update request according to the server cache identifier and the response data, and send the data response request to the client.
9. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to implement the steps in the data update method described in any one of claims 1 to 5 or to execute the steps in the data update method described in any one of claims 6 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the data updating method described in any one of claims 1 to 5 or the steps in the data updating method described in any one of claims 6 to 7.