Data processing method and apparatus, and electronic device
By obtaining the timestamp update request set from the application and comparing it with the interface request identifier, cached data can be directly retrieved, solving the problem of data retrieval failure caused by outdated cached data and ensuring the stability of the interface display.
Patent Information
- Application Number
- CN202210302371.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-25
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-03-25
AI Technical Summary
In the application, the cached data of the timestamp update interface may become inconsistent with the locally stored timestamp due to manual clearing by the user, resulting in the inability to retrieve the cached data and affecting the display of the interface.
By obtaining a set of timestamp update requests from the target application and comparing them with the interface request identifiers called by the target control, cached data can be directly retrieved from the server, ensuring that the latest cached data can be obtained even if the cached data has not yet reached the update time.
This ensures the validity of cached data from the timestamp update interface when it is displayed on the screen, avoiding data retrieval failures due to outdated cached data and ensuring the stability of the screen display.
Smart Images

Figure CN114625395B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a data processing method, apparatus, and electronic device. Background Technology
[0002] As application (APP) business capabilities develop, APP functions are becoming more and more numerous, and the interfaces involved in the functional interfaces are also increasing.
[0003] Currently, the interface contains a type of timestamp update interface. The timing of updating the cached data corresponding to this type of timestamp update interface is determined by the timestamp returned by the timestamp delivery interface. If the timestamp currently returned by the timestamp delivery interface is the same as the previously returned timestamp, then there is no need to update the cached data of the timestamp update interface corresponding to that timestamp. If the timestamp currently returned by the timestamp delivery interface is different from the previously returned timestamp, then it is necessary to request an update to the cached data of the timestamp update interface.
[0004] For example, please refer to Figure 1 It shows a schematic diagram of a target interface. For example... Figure 1 As shown, the target interface 100 includes a navigation bar interface 101. The navigation bar interface 101 is a timestamp update interface, and the update timing of its corresponding cached data is determined based on the timestamp returned by the jump interface. This jump interface is the timestamp distribution interface corresponding to the navigation bar interface, used for jumping to the target interface. Each time the terminal receives an instruction to jump to the target interface, it can request the interface data of the target interface through the jump interface. The interface data returned through the jump interface includes the timestamp corresponding to the navigation bar interface. The terminal can locally store the timestamp corresponding to the navigation bar interface, and upon receiving the interface data returned by the jump interface again, compare the timestamp included in the interface data with the locally stored timestamp. Based on the comparison result, it determines whether it is necessary to request an update of the cached data corresponding to the navigation bar interface. The cached data corresponding to the navigation bar interface includes its display data: live broadcasts, recommendations, TV series, and movies.
[0005] However, since the cached data for the app can be manually cleared by the user, there's a possibility that the cached data for the timestamp update interface might be cleared, while the corresponding locally stored timestamp might not. This could lead to a situation where, if the timestamp returned by the timestamp delivery interface matches the locally stored timestamp, the cached data for the timestamp update interface might not be retrieved. Summary of the Invention
[0006] The purpose of this application is to provide a data processing method, apparatus, and electronic device that, to a certain extent, ensures the effective acquisition of cached data corresponding to the timestamp update interface. The specific technical solution is as follows:
[0007] In a first aspect of this invention, a data processing method is provided, the method comprising:
[0008] When entering the interface of the target application including the target control, the timestamp update request set and the first request identifier of the first data request corresponding to the first interface are obtained. The first interface is the interface called by the target control. The timestamp update request set is used to record the request identifier of the data request corresponding to the timestamp update interface in the target application.
[0009] The request identifiers included in the timestamp update request set are compared with the first request identifier;
[0010] When the first request identifier exists in the timestamp update request set, the first cached data corresponding to the first interface is obtained from the server through the first interface.
[0011] Optionally, before obtaining the set of timestamp update requests, the method includes:
[0012] A second data request is sent to the server through the second interface;
[0013] Receive the second cached data returned by the server through the second interface;
[0014] When the second cached data includes a first type identifier, the second request identifier of the second data request is added to the timestamp update request set, and the first type identifier is used to indicate that the second interface is the timestamp update interface.
[0015] Optionally, when the second cached data includes a first type identifier, adding the second request identifier to the timestamp update request set includes:
[0016] When the second cached data includes a first type identifier and a deletion operation for the second cached data is received, the second request identifier is added to the timestamp update request set.
[0017] Optionally, before obtaining the set of timestamp update requests, the method includes:
[0018] A second data request is sent to the server through the second interface;
[0019] Receive the second cached data returned by the server through the second interface;
[0020] When the second cached data includes a first type identifier, the mapping relationship between the data identifier of the second cached data and the second request identifier is recorded;
[0021] Monitor the data of the target application;
[0022] Upon receiving a deletion operation for any target cached data in the data, the data identifier included in the mapping relationship is compared with the target data identifier of the target cached data;
[0023] When the target data identifier exists in the data identifiers included in the mapping relationship, the request identifier corresponding to the target data identifier in the mapping relationship is added to the timestamp update request set.
[0024] Optionally, the data identifier of the second cached data includes: the storage path of the second cached data, the storage time encoding identifier of the second cached data, or an identifier generated by concatenating the storage path and the storage time encoding of the second cached data.
[0025] Optionally, the request identifier includes: the class name of the data request, or the identifier characters included in the data request.
[0026] Optionally, when the second cached data includes the first type identifier, adding the second request identifier to the timestamp update request set includes:
[0027] When a target event is detected using a hook function, a target processing method is executed. The target processing method includes: when the second cached data includes the first type identifier, adding the second request identifier to the timestamp update request set. The target event is the event of receiving the second cached data returned by the server through the second interface.
[0028] In a second aspect of the invention, a data processing apparatus is also provided, the apparatus comprising:
[0029] The first acquisition module is used to acquire a timestamp update request set and a first request identifier of a first data request corresponding to a first interface when entering the interface of the target application including the target control. The first interface is the interface called by the target control. The timestamp update request set is used to record the request identifier of the data request corresponding to the timestamp update interface in the target application.
[0030] The comparison module is used to compare the request identifiers included in the timestamp update request set with the first request identifier.
[0031] The second acquisition module is used to acquire the first cached data corresponding to the first interface from the server through the first interface when the first request identifier exists in the timestamp update request set.
[0032] In a third aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.
[0033] Memory, used to store computer programs;
[0034] When a processor executes a program stored in memory, it implements any of the steps described in the first aspect above.
[0035] In a fourth aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.
[0036] Memory, used to store computer programs;
[0037] When a processor executes a program stored in memory, it implements any of the steps described in the second aspect above.
[0038] In a fifth aspect of the invention, a computer-readable storage medium is also provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform any of the data processing methods described in the first aspect above.
[0039] The data processing method, apparatus, and electronic device provided in this application, when entering an interface of a target application including a target control, acquires a timestamp update request set and a first request identifier of a first data request corresponding to a first interface called by the target control. The request identifiers included in the timestamp update request set are compared with the first request identifier. Since the timestamp update request set is used to record the request identifiers of data requests corresponding to timestamp update interfaces in the target application, the comparison between the request identifiers included in the timestamp update request set and the first data identifier determines whether the first interface is a timestamp update interface. Therefore, when the timestamp update request set contains a first request identifier, i.e., when the first interface is determined to be a timestamp update interface, it is not necessary to determine whether the update timing of the first cached data of the first interface has been reached; the first cached data can be directly obtained through the first interface. In this technical solution, for a determined timestamp update interface, regardless of whether the cached data of the timestamp update interface has reached the update timing, the step of requesting the cached data corresponding to the timestamp update interface from the server through the timestamp update interface is executed to obtain the cached data of the timestamp update interface. Therefore, compared to related technologies, this avoids the problem of not being able to retrieve cached data when entering the interface due to the cached data being deleted when the cached data of the timestamp update interface has not reached the update time, i.e., the cached data cannot be retrieved from the server, thus ensuring the effectiveness of the use of cached data. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0041] Figure 1 This is a schematic diagram of a target interface provided in an embodiment of this application;
[0042] Figure 2 A flowchart illustrating a data processing method provided in an embodiment of this application;
[0043] Figure 3 A flowchart illustrating another data processing method provided in this application embodiment;
[0044] Figure 4 A flowchart illustrating yet another data processing method provided in this application embodiment;
[0045] Figure 5 A structural diagram of a data processing apparatus provided in an embodiment of this application;
[0046] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0047] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0048] Please refer to Figure 2 This document illustrates a flowchart of a data processing method provided by an embodiment of this application. The data processing method can be executed by a terminal (also known as a front-end). For example, the terminal can be a mobile phone, a personal computer (PC), or a tablet computer, etc. Figure 2 As shown, the data processing methods include:
[0049] Step 201: When entering the interface of the target application that includes the target control, obtain the timestamp update request set and the first request identifier of the first data request corresponding to the first interface. The first interface is the interface called by the target control, and the timestamp update request set is used to record the request identifier of the data request corresponding to the timestamp update interface in the target application.
[0050] In this embodiment, the interface of the target application may include one or more controls. When the interface includes multiple controls, the target control may refer to any one of the multiple controls, and one control corresponds to one interface. The first data request is used to request first cached data from the server through the first interface corresponding to the target control. Optionally, the first cached data may include display data of the target control and / or style data of the target control, etc.
[0051] The target application may include one or more interfaces. An interface may include one or more controls corresponding to the timestamp update interface. A timestamp update request set is used to record the request identifiers of data requests corresponding to the timestamp update interface in the target application. When the terminal sends a data request corresponding to the timestamp update interface to the server through the timestamp update interface, the server can send the cached data corresponding to that timestamp update interface to the terminal. The timestamp update interface is an interface that determines the update timing of cached data based on timestamps returned by other interfaces; these other interfaces can be called timestamp delivery interfaces. The update timing of the cached data of the timestamp update interface is determined based on the consistency of the first timestamp and the second timestamp. When the first timestamp and the second timestamp are the same, there is no need to update the cached data of the timestamp update interface; when the first timestamp and the second timestamp are different, the cached data of the timestamp update interface is updated. The first timestamp is the timestamp currently returned by the server through the timestamp delivery interface. The initial value of the second timestamp is a set value. The non-initial value of the second timestamp is the timestamp previously returned by the server through the timestamp delivery interface. In related technologies, the terminal locally stores the second timestamp, and the initial value of this second timestamp is Null. After receiving the first timestamp returned by the server via the timestamp distribution interface, the terminal can perform a consistency check between the first and second timestamps. Based on the consistency check result, it determines whether to update the cached data of the timestamp update interface. After the consistency check is complete, the value of the second timestamp is updated to the value of the first timestamp. Upon receiving the first timestamp returned by the server again via the timestamp distribution interface, the consistency between the first and second timestamps is used to determine the update timing. It's easy to understand that the update timing of the cached data in the timestamp update interface is primarily determined by the consistency of two consecutive timestamps returned by the timestamp distribution interface.
[0052] In this embodiment, the timestamp update request set may include one or more request identifiers. The request identifier is used to indicate a data request. The request identifier may include: the class name of the data request, or an identifier character included in the data request. This identifier character may be a number, letter, or other type of character used to uniquely identify the data request. It should be noted that the first request identifier may include the class name of the first data request, or an identifier character included in the first data request. Furthermore, the content of the first request identifier corresponds to the content of the request identifier. That is, when the request identifier included in the timestamp update request set is the class name of the data request, the first request identifier is the class name of the first data request. When the request identifier included in the timestamp update request set is an identifier character included in the data request, the first request identifier is the identifier character included in the first data request.
[0053] Optionally, the terminal may pre-store a set of timestamp update requests. Alternatively, the terminal may obtain the set of timestamp update requests from the server when initializing the target application. The set of timestamp update requests may be generated by developers based on the timestamp update interfaces determined by the configuration data of each interface in the target application. The interface configuration data includes data indicating the interface type. Alternatively, the set of timestamp update requests may be generated by the terminal based on the update timing indication information for each interface issued by the server. The update timing indication information is used to indicate the update timing of the cached data of the interface. The terminal identifies the interface corresponding to the target indication information in the update timing indication information of each interface as the timestamp update interface, and then collects the request identifier of the data request corresponding to the timestamp update interface. The target indication information used to indicate the update timing of the interface is determined based on the timestamp returned by the interface corresponding to the timestamp.
[0054] Step 202: Compare the request identifiers included in the timestamp update request set with the first request identifier.
[0055] In this embodiment, the terminal can compare the first request identifier with the request identifiers included in the timestamp update request set sequentially to determine whether the first request identifier exists in the timestamp update request set. This determines whether the first interface corresponding to the first request identifier is a timestamp update interface.
[0056] Step 203: When the first request identifier exists in the timestamp update request set, obtain the first cached data corresponding to the first interface from the server through the first interface.
[0057] In this embodiment, when a first request identifier exists in the timestamp update request set, it indicates that the first interface corresponding to the first request identifier is a timestamp update interface. The terminal can then generate a first data request and send it to the server through the first interface, enabling the server to receive the first data request and, in response, send first cached data to the terminal's first interface. This allows the terminal to receive the first cached data returned from the server through the first interface.
[0058] In this embodiment, when the first request identifier is not present in the timestamp update request set, it indicates that the first interface corresponding to the first request identifier is a non-timestamp update interface. The terminal can then obtain the first cached data of the first interface corresponding to the first request identifier according to the cached data request logic of the non-timestamp update interface. For example, the cached data request logic of the non-timestamp update interface may include: generating a first data request when entering an interface including a control corresponding to the non-timestamp update interface, and sending the first data request to the server through the first interface, so that the server receives the first data request and, in response to the first data request, sends the first cached data to the terminal's first interface. This allows the terminal to receive the first cached data returned from the server through the first interface.
[0059] For example, targeting Figure 1 The interface shown includes the control corresponding to navigation bar interface 101 as the target control. The timestamp update request set includes the request identifier of the data request corresponding to the navigation bar interface. When the terminal receives a trigger operation for the control corresponding to the jump interface, it jumps to the target control in response to the trigger operation. Figure 1 The interface shown is for entering... Figure 1 The interface shown illustrates this. The terminal obtains the timestamp update request set and the first request identifier of the first data request corresponding to the navigation bar interface. The terminal determines that the timestamp update request set includes the first request identifier by comparing the first request identifier with the request identifiers included in the timestamp update request set. The terminal then obtains the first cached data corresponding to the navigation bar interface from the server through the navigation bar interface. This first cached data includes the display data of the controls corresponding to the navigation bar interface: live streams, recommendations, TV series, and movies.
[0060] In summary, the data processing method provided in this application, upon entering an interface of a target application including a target control, obtains a timestamp update request set and a first request identifier of the first data request corresponding to the first interface called by the target control. The request identifiers included in the timestamp update request set are compared with the first request identifier. Since the timestamp update request set records the request identifiers of data requests corresponding to timestamp update interfaces in the target application, the comparison between the request identifiers included in the timestamp update request set and the first data identifier determines whether the first interface is a timestamp update interface. Therefore, when the timestamp update request set contains the first request identifier, i.e., when the first interface is determined to be a timestamp update interface, it is not necessary to determine whether the update timing of the first cached data of the first interface has been reached; the first cached data can be directly obtained through the first interface. In this technical solution, for a determined timestamp update interface, regardless of whether the cached data of the timestamp update interface has reached the update timing, the step of requesting the cached data corresponding to the timestamp update interface from the server through the timestamp update interface is executed to obtain the cached data of the timestamp update interface. Therefore, compared to related technologies, this avoids the problem of not being able to retrieve cached data when entering the interface due to the cached data being deleted when the cached data of the timestamp update interface has not reached the update time, i.e., the cached data cannot be retrieved from the server, thus ensuring the effectiveness of the use of cached data.
[0061] In this embodiment, the request identifier recorded in the timestamp update request set can be dynamically added to the timestamp update request set by the terminal. Based on this, the data processing method provided in this embodiment can include: a method for adding a request identifier to the timestamp update request set by the terminal, and a method for applying the timestamp update request set. There can be multiple ways for the terminal to add a request identifier to the timestamp update request set. This embodiment uses... Figure 3 and Figure 4 The following two data processing methods are used as examples to illustrate the process of adding a request identifier to the timestamp update request set by the terminal.
[0062] Please refer to Figure 3 This document illustrates a flowchart of a data processing method provided in an embodiment of this application. The data processing method can be executed by a terminal (also known as a front-end). Figure 3 As shown, the data processing method includes the adding method shown in steps 301 to 303 and the application method shown in steps 304 to 306. Specifically, the data processing method includes:
[0063] Step 301: Send a second data request to the server through the second interface.
[0064] In this embodiment, the terminal can send a second data request to the server through a second interface under a set trigger condition. The second data request is used to request second cached data corresponding to the second interface from the server through the second interface. The second interface can be an interface corresponding to any control included in any interface of the target application. The second interface can be a timestamp update interface, or it can be a non-timestamp update interface. The set trigger condition can be a sending time set by the developer.
[0065] Optionally, the trigger condition can be a specific time. For example, the trigger condition can be set to year A month A day A hour A minute A second. Alternatively, the trigger condition can also be the timing of the sending of the second data request under the cached data request logic of the second interface.
[0066] For example, when the second interface is a timestamp update interface, the trigger condition can be that the first timestamp issued by the timestamp issuance interface corresponding to the timestamp update interface is different from the second timestamp stored locally. Specifically, when the timestamp issuance interface corresponding to the second interface has never issued a first timestamp, the second interface has never requested second cached data from the server, and the second timestamp stored locally is an empty string, such as null. After receiving the first timestamp issued by the timestamp issuance interface corresponding to the second interface, the terminal compares the first timestamp with the locally stored null string to determine that the first timestamp is different from the locally stored null string. Then, the terminal can send a second data request to the server for the first time through the second interface to obtain the second cached data from the server through the second interface.
[0067] When the second interface is a non-timestamp update interface, the trigger condition can be set to the trigger time of the control corresponding to the second interface. For example, the second interface is... Figure 1 The example shown illustrates a jump interface. When the terminal receives a trigger operation for the control corresponding to the jump interface, it generates a second data request in response to the trigger operation and sends the second data request to the server through the second interface.
[0068] Step 302: Receive the second cached data returned by the server through the second interface.
[0069] In this embodiment, the terminal sends a second data request to the server through a second interface, enabling the server to receive the second data request and, in response, send second cached data to the terminal's second interface. The terminal then receives the second cached data returned by the server through the second interface.
[0070] Upon receiving a second data request, the server can determine whether the corresponding second interface is a timestamp update interface. If the second interface is determined to be a timestamp update interface, second cached data including a first type identifier is generated. This first type identifier indicates that the second interface is a timestamp update interface. If the second interface is determined not to be a timestamp update interface, second cached data without the first type identifier can be generated. Optionally, the second cached data may include a second type identifier, which indicates that the second interface is not a timestamp update interface.
[0071] In one optional implementation, the second cached data may include a flag field (updateByTimestamp). The value of the flag field is used to indicate whether the second interface is a timestamp update interface. The first type identifier can be the target value of the flag field. For example, when the flag field is set to 1, it indicates that the second interface is a timestamp update interface. When the flag field is set to 0, it indicates that the second interface is not a timestamp update interface, that is, it is a non-timestamp update interface.
[0072] In another alternative implementation, the first type identifier can be a flag character (updateByTimestamp). When the second interface is a timestamp update interface, the generated second cache data includes the flag character. When the second interface is not a timestamp update interface, the generated second cache data does not include the flag character.
[0073] Optionally, the server may pre-store a set of interface identifiers, which includes the interface identifiers corresponding to the timestamp update interface in the target application. The second data request may include the interface identifier of the second interface. After receiving the second data request, the server can determine whether the set of interface identifiers includes the interface identifiers included in the second data request. If the set of interface identifiers includes the interface identifier of the second interface, the second interface is determined to be a timestamp update interface. If the set of interface identifiers does not include the interface identifier of the second interface, the second interface is determined not to be a timestamp update interface. The interface identifier can be an interface address or an interface name, etc.
[0074] For example, the server may pre-store a set of interface identifiers. When it is determined that the set of interface identifiers includes the interface identifier of the second interface, the second interface is determined to be a timestamp update interface, and second cache data including the first type identifier is generated. When the set of interface identifiers does not include the interface identifier of the second interface, the second interface is determined not to be a timestamp update interface, and cache data excluding the first type identifier is generated.
[0075] Step 303: When the second cached data includes the first type identifier, add the second request identifier of the second data request to the timestamp update request set. The first type identifier is used to indicate that the second interface is a timestamp update interface.
[0076] In this embodiment, after receiving the second cached data returned through the second interface, the terminal can parse the second cached data to determine whether it includes a first type identifier, thereby determining whether the second interface is a timestamp update interface. If the second cached data includes the first type identifier, it indicates that the second interface is a timestamp update interface, and the second request identifier is added to the timestamp update request set. The timestamp update request set is used to record the request identifiers of data requests corresponding to the timestamp update interface in the target application. If the cached data does not include the first type identifier, the second cached data is stored.
[0077] For example, the terminal can use a hook function to listen for target events. When a target event is detected using the hook function, a target processing method is executed. The target processing method includes: when the second cached data includes a first type identifier, adding a second request identifier to the timestamp update request set. The target event is the event of receiving the second cached data returned by the server through a second interface.
[0078] For example, in related technical solutions, when a terminal receives cached data returned by the server through any interface, it can execute the original interface data storage method. This original interface data storage method includes: formatting the received cached data using a pre-defined data formatting method of the request manager, and storing the processed data at the storage address indicated by the key path. The data format of the storage address indicated by the key path is a string object (NSString).
[0079] In this embodiment, a hook function is used to listen for target events. Upon detecting a target event, the original interface data storage method is not executed; instead, the target processing method is executed. The target processing method includes processing the received cached data using a pre-defined data processing method of the new request manager. This data processing method determines whether the second cached data includes a first type identifier. If the second cached data includes the first type identifier, the second request identifier is added to the timestamp update request set, and the second cached data is stored at the storage address indicated by the key path. If the second cached data does not include the first type identifier, the second cached data is directly stored at the storage address indicated by the key path.
[0080] Optionally, when the second cached data includes a first type identifier, the process of adding the second request identifier of the second data request to the timestamp update request set may include: when the second cached data includes a first type identifier and a deletion operation for the second cached data is received, the terminal adds the second request identifier to the timestamp update request set.
[0081] In this embodiment, the terminal can monitor the second cached data after determining that the second cached data includes a first type identifier. Receiving a deletion operation for the second cached data indicates that the second cached data has been deleted. However, if, before the terminal needs to retrieve the second cached data, the first timestamp issued by the timestamp sending interface corresponding to the second interface is consistent with the second timestamp of the locally cached second interface (meaning the second cached data has not reached its update time), the terminal cannot retrieve the second cached data, resulting in abnormal data display. Therefore, upon receiving a deletion operation for the second cached data, a second request identifier can be added to the timestamp update request set. This allows the terminal to determine that the second interface is a timestamp update interface and that the second cached data has been deleted by judging that the timestamp update request set includes the second request identifier when it subsequently enters an interface including the control corresponding to the second interface (i.e., when it needs to retrieve the second cached data). This eliminates the need to determine whether the update time for the second cached data is met; the terminal can directly retrieve the second cached data from the server by executing the step of retrieving the second cached data through the second interface, ensuring that the terminal can retrieve the second cached data.
[0082] Step 304: When entering the interface of the target application that includes the target control, obtain the timestamp update request set and the first request identifier of the first data request corresponding to the first interface, where the first interface is the interface called by the target control.
[0083] Step 305: Compare the request identifiers included in the timestamp update request set with the first request identifier.
[0084] Step 306: When the first request identifier exists in the timestamp update request set, obtain the first cached data corresponding to the first interface from the server through the first interface.
[0085] The explanations and implementation methods of steps 304 to 306 can be referred to the explanations and implementation methods of steps 201 to 203 above, and will not be repeated in this embodiment.
[0086] It should be noted that when the request identifier recorded in the timestamp update request set is dynamically added by the terminal, the absence of the first request identifier in the timestamp update request set does not necessarily indicate that the first interface is not a timestamp update interface. It could be the initial timestamp update interface that has never requested cached data from the server. Therefore, after determining that the timestamp update request set does not contain the first request identifier, the terminal can perform the first cached data request according to the cached data request logic of the timestamp update interface. That is, when the first timestamp issued by the timestamp issuing interface corresponding to the first interface is inconsistent with the second timestamp stored locally, the terminal obtains the first cached data from the server through the first interface. After obtaining the first cached data through the first interface, the terminal can perform the step of determining whether the first cached data includes the first type identifier. If the first cached data includes the first type identifier, the terminal adds the first request identifier of the first data request to the timestamp update request set, facilitating subsequent determination that the first interface is a timestamp interface based on the timestamp update request set. In this embodiment of the application, when the terminal adds the first request identifier to the timestamp update request set when the first cached data includes the first type identifier, the implementation method can refer to the implementation method of the aforementioned step 303, and this embodiment of the application will not elaborate on this.
[0087] Please refer to Figure 4 This illustrates a flowchart of another data processing method provided in an embodiment of this application. The data processing method can be executed by a terminal (also known as a front-end). Figure 4 As shown, the data processing method includes the adding method shown in steps 401 to 406 and the application method shown in steps 407 to 409. The data processing method specifically includes:
[0088] Step 401: Send a second data request to the server through the second interface.
[0089] The explanation and implementation of step 401 can be found in the explanation and implementation of step 301 above, and will not be repeated in this embodiment.
[0090] Step 402: Receive the second cached data returned by the server through the second interface.
[0091] The explanation and implementation of step 402 can be found in the explanation and implementation of step 302 above, and will not be repeated in this embodiment.
[0092] Step 403: When the second cached data includes the first type identifier, record the mapping relationship between the data identifier of the second cached data and the second request identifier.
[0093] In this embodiment, after receiving the second cached data returned through the second interface, the terminal can parse the second cached data to determine whether it includes the first type identifier, thereby determining whether the second interface is a timestamp update interface. If the second cached data does not include the first type identifier, it indicates that the second interface is a non-timestamp update interface, and the second cached data is stored.
[0094] When the second cached data includes a first type identifier, it indicates that the second interface is a timestamp update interface, and the terminal can record the mapping relationship between the data identifier of the second cached data and the second request identifier. Optionally, the data identifier of the second cached data can be the storage path of the second cached data, the storage time encoding identifier of the second cached data, or an identifier generated by concatenating the storage path and storage time encoding of the second cached data. For example, the terminal can record the mapping relationship between the data identifier of the second cached data and the second request identifier through a mapping table. The format of the mapping table is keypath = [manager class]. Wherein, keypath represents the storage path of the second cached data, that is, the data identifier of the second cached data. [manager class] represents the class name of the second data request, that is, the second request identifier.
[0095] Step 404: Monitor the target application's data.
[0096] In this embodiment, the terminal can monitor all or part of the cached data of the target application it stores. Specifically, the terminal can monitor the data under the sandbox target file corresponding to the target application. Alternatively, the terminal can monitor cached data of a target file type, where the target file type is the file type of cached data corresponding to the timestamp update interface. This achieves precise monitoring of the cached data corresponding to the required timestamp update interface, avoiding resource waste and saving processing overhead compared to monitoring all cached data under the sandbox target file, which would otherwise be inefficient in monitoring unnecessary cached data.
[0097] Step 405: When a deletion operation is received for any target cached data in the data, the data identifier included in the mapping relationship is compared with the target data identifier of the target cached data.
[0098] In this embodiment, when the terminal receives a deletion operation for any target cached data in the data, it can compare the target data identifier with the data identifiers included in the mapping relationship in sequence to determine whether the target cached data's target data identifier exists in the mapping relationship. Then, it can determine whether the deleted target cached data is the cached data corresponding to the timestamp update interface.
[0099] Step 406: If a target data identifier exists in the data identifiers included in the mapping relationship, add the request identifier corresponding to the target data identifier in the mapping relationship to the timestamp update request set.
[0100] In this embodiment, when a target data identifier exists among the data identifiers included in the mapping relationship, it indicates that the target cached data is cached data of the timestamp update interface, and it is necessary to avoid the situation where the terminal cannot obtain the cached data when the update timing is not met. Therefore, the terminal adds the request identifier corresponding to the target data identifier in the mapping relationship to the timestamp update request set. This facilitates the terminal's subsequent determination that the interface corresponding to the target cached data is a timestamp update interface and that the target cached data has been deleted, by judging that the timestamp update request set includes the request identifier corresponding to the target data identifier. Consequently, there is no need to determine whether the update timing of the target cached data is met; the terminal can directly obtain the target cached data from the server by executing the step of obtaining the target cached data from the server, ensuring that the terminal can obtain the target cached data.
[0101] If the target data identifier is not present in the data identifiers included in the mapping relationship, it indicates that the target cached data is not cached data of the timestamp update interface, and the terminal can continue to delete the target cached data.
[0102] For example, the terminal can use a hook function to listen for target events. When a target event is detected using the hook function, a target processing method is executed. The target processing method includes: when the second cached data includes a first type identifier, recording the mapping relationship between the data identifier of the second cached data and the second request identifier; monitoring the data of the target application; when a deletion operation is received for any target cached data in the data, comparing the data identifier included in the mapping relationship with the target data identifier of the target cached data; and when a target data identifier exists among the data identifiers included in the mapping relationship, adding the request identifier corresponding to the target data identifier in the mapping relationship to the timestamp update request set. Here, the target event is the event of receiving second cached data returned by the server through a second interface.
[0103] For example, in related technical solutions, when a terminal receives cached data returned by the server through any interface, it can execute the original interface data storage method. This original interface data storage method includes: formatting the received cached data using a pre-defined data formatting method of the request manager, and storing the processed data at the storage address indicated by the key path. The data format of the storage address indicated by the key path is a string object (NSString).
[0104] In this embodiment, a hook function is used to listen for target events. Upon detecting a target event, the original interface data storage method is not executed; instead, a target processing method is executed. The target processing method includes: processing the received cached data using a pre-defined data processing method of the new request manager. This data processing method stores the second cached data according to the storage address indicated by the key path. It also determines whether the second cached data includes a first type identifier. If the second cached data includes a first type identifier, the mapping relationship between the data identifier of the second cached data and the second request identifier is recorded. The target application's data is monitored. When a deletion operation is received for any target cached data, the data identifier included in the mapping relationship is compared with the target data identifier of the target cached data. If the target data identifier exists among the data identifiers included in the mapping relationship, the request identifier corresponding to the target data identifier in the mapping relationship is added to the timestamp update request set.
[0105] In this embodiment, the terminal can be equipped with either an Android or iOS system. When the terminal is equipped with an iOS system, the data processing method provided in this embodiment can be executed by a software program written in Objective-C. The terminal can then utilize the dynamism and runtime mechanism of Objective-C to write hook functions. Since the terminal can directly intercept the original interface data storage method using hook functions and replace it with the target processing method, the data processing method of this embodiment is implemented efficiently and conveniently without intruding on the original code.
[0106] Step 407: When entering the interface of the target application that includes the target control, obtain the timestamp update request set and the first request identifier of the first data request corresponding to the first interface, where the first interface is the interface called by the target control.
[0107] Step 408: Compare the request identifiers included in the timestamp update request set with the first request identifier.
[0108] Step 409: When the timestamp update request set contains a first request identifier, obtain the first cached data corresponding to the first interface from the server through the first interface.
[0109] The explanations and implementation methods of steps 407 to 409 can be referred to the explanations and implementation methods of steps 201 to 203 above, and will not be repeated in this embodiment.
[0110] In summary, the data processing method provided in this application, upon entering an interface of a target application including a target control, obtains a timestamp update request set and a first request identifier of the first data request corresponding to the first interface called by the target control. The request identifiers included in the timestamp update request set are compared with the first request identifier. Since the timestamp update request set records the request identifiers of data requests corresponding to timestamp update interfaces in the target application, the comparison between the request identifiers included in the timestamp update request set and the first data identifier determines whether the first interface is a timestamp update interface. Therefore, when the timestamp update request set contains the first request identifier, i.e., when the first interface is determined to be a timestamp update interface, it is not necessary to determine whether the update timing of the first cached data of the first interface has been reached; the first cached data can be directly obtained through the first interface. In this technical solution, for a determined timestamp update interface, regardless of whether the cached data of the timestamp update interface has reached the update timing, the step of requesting the cached data corresponding to the timestamp update interface from the server through the timestamp update interface is executed to obtain the cached data of the timestamp update interface. Therefore, compared to related technologies, this approach avoids the problem of cached data being unavailable upon entering the interface due to deletion of cached data before the timestamp update interface reaches its update time (i.e., when cached data cannot be retrieved from the server). This ensures the effectiveness of cached data usage and prevents abnormal interface display caused by the terminal's inability to retrieve cached data, thus avoiding impacts on performance and user experience.
[0111] Furthermore, compared to the method that requires programmers to manually delete timestamps based on user feedback after the user deletes the timestamp to update the corresponding cached data, the data processing method provided in this application can automatically solve the problem of being unable to retrieve cached data due to its deletion before the update timing is met, thus improving data processing efficiency.
[0112] Please refer to Figure 5 This illustrates a block diagram of a data processing apparatus provided in an embodiment of this application. Figure 5 As shown, the data processing device 500 includes: a first acquisition module 501, a comparison module 502, and a second acquisition module 503.
[0113] The first acquisition module 501 is used to acquire a timestamp update request set and a first request identifier of a first data request corresponding to a first interface when entering the interface of the target application including the target control. The first interface is the interface called by the target control, and the timestamp update request set is used to record the request identifier of the data request corresponding to the timestamp update interface in the target application.
[0114] Comparison module 502 is used to compare the request identifiers included in the timestamp update request set with the first request identifier;
[0115] The second acquisition module 503 is used to obtain the first cached data corresponding to the first interface from the server through the first interface when the first request identifier exists in the timestamp update request set.
[0116] Optionally, the data processing device 500 further includes:
[0117] The sending module is used to send a second data request to the server through the second interface;
[0118] The receiving module is used to receive the second cached data returned by the server through the second interface;
[0119] An add module is used to add the second request identifier of the second data request to the timestamp update request set when the second cached data includes the first type identifier. The first type identifier is used to indicate that the second interface is a timestamp update interface.
[0120] Optionally, the module is further configured to add the second request identifier to the timestamp update request set when the second cached data includes the first type identifier and a deletion operation for the second cached data is received.
[0121] Optionally, the data processing device 500 further includes:
[0122] The sending module is used to send a second data request to the server through the second interface;
[0123] The receiving module is used to receive the second cached data returned by the server through the second interface;
[0124] The recording module is used to record the mapping relationship between the data identifier of the second cached data and the second request identifier when the second cached data includes the first type identifier;
[0125] The monitoring module is used to monitor the data of the target application;
[0126] The comparison module 502 is also used to compare the data identifier included in the mapping relationship with the target data identifier of the target cache data when a deletion operation for any target cache data in the data is received.
[0127] The data processing device 500 further includes an adding module, used to add the request identifier corresponding to the target data identifier in the mapping relationship to the timestamp update request set when a target data identifier exists in the data identifiers included in the mapping relationship.
[0128] Optionally, the data identifier of the second cached data includes: the storage path of the second cached data, the storage time encoding identifier of the second cached data, or an identifier generated by concatenating the storage path and storage time encoding of the second cached data.
[0129] Optionally, the request identifier may include: the class name of the data request, or the identifier characters included in the data request.
[0130] Optionally, the module is also used to execute a target processing method when a target event is detected by using a hook function. The target processing method includes: when the second cached data includes a first type identifier, adding a second request identifier to a timestamp update request set. The target event is the event of receiving the second cached data returned by the server through the second interface.
[0131] In summary, the data processing apparatus provided in this application, upon entering an interface of a target application including a target control, acquires a timestamp update request set and a first request identifier of a first data request corresponding to a first interface called by the target control. The request identifiers included in the timestamp update request set are compared with the first request identifier. Since the timestamp update request set records the request identifiers of data requests corresponding to timestamp update interfaces in the target application, the comparison between the request identifiers included in the timestamp update request set and the first data identifier determines whether the first interface is a timestamp update interface. Therefore, when the timestamp update request set contains a first request identifier, i.e., when the first interface is determined to be a timestamp update interface, it is not necessary to determine whether the update timing of the first cached data of the first interface has been reached; the first cached data can be directly obtained through the first interface. In this technical solution, for a determined timestamp update interface, regardless of whether the cached data of the timestamp update interface has reached the update timing, the step of requesting the cached data corresponding to the timestamp update interface from the server through the timestamp update interface is executed to obtain the cached data of the timestamp update interface. Therefore, compared to related technologies, this avoids the problem of not being able to retrieve cached data when entering the interface due to the cached data being deleted when the cached data of the timestamp update interface has not reached the update time, i.e., the cached data cannot be retrieved from the server, thus ensuring the effectiveness of the use of cached data.
[0132] This application also provides an electronic device, which can be the aforementioned terminal or server. For example... Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0133] Memory 603 is used to store computer programs;
[0134] The processor 601, when executing the program stored in the memory 603, implements any of the data processing methods provided in the embodiments of this application.
[0135] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.
[0136] Communication interface 604 is used for communication between the above-mentioned electronic devices and other devices.
[0137] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0138] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0139] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a terminal's processor, performs the steps of the data processing method described in any of the above embodiments, or when executed by a server's processor, performs the steps of the data processing method described in any of the above embodiments.
[0140] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the steps executed by the terminal in any of the data processing methods described in the above embodiments, or to perform the steps executed by the server in any of the data processing methods described in the above embodiments.
[0141] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0142] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the term "and / or" means "and" and "or." For example, "A and / or B" means: A, B, and A and B. The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0143] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0144] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A data processing method, characterized in that, The method includes: When entering the interface of the target application including the target control, the timestamp update request set and the first request identifier of the first data request corresponding to the first interface are obtained. The first interface is the interface called by the target control. The timestamp update request set is used to record the request identifier of the data request corresponding to the timestamp update interface in the target application. The request identifiers included in the timestamp update request set are compared with the first request identifier; When the first request identifier exists in the timestamp update request set, the first cached data corresponding to the first interface is obtained from the server through the first interface. Before obtaining the set of timestamp update requests, the method includes: A second data request is sent to the server through the second interface; Receive the second cached data returned by the server through the second interface; When the second cached data includes a first type identifier, the second request identifier of the second data request is added to the timestamp update request set, and the first type identifier is used to indicate that the second interface is the timestamp update interface; Alternatively, when the second cached data includes a first type identifier, record the mapping relationship between the data identifier of the second cached data and the second request identifier; monitor the data of the target application; when a deletion operation is received for any target cached data in the data, compare the data identifier included in the mapping relationship with the target data identifier of the target cached data; when the target data identifier exists in the data identifier included in the mapping relationship, add the request identifier corresponding to the target data identifier in the mapping relationship to the timestamp update request set.
2. The method according to claim 1, characterized in that, When the second cached data includes a first type identifier, adding the second request identifier to the timestamp update request set includes: When the second cached data includes a first type identifier and a deletion operation for the second cached data is received, the second request identifier is added to the timestamp update request set.
3. The method according to claim 1, characterized in that, The data identifier of the second cached data includes: the storage path of the second cached data, the storage time encoding identifier of the second cached data, or an identifier generated by concatenating the storage path and storage time encoding of the second cached data.
4. The method according to claim 1, characterized in that, The request identifier includes: the class name of the data request, or the identifier characters included in the data request.
5. The method according to claim 1, characterized in that, When the second cached data includes the first type identifier, adding the second request identifier to the timestamp update request set includes: When a target event is detected using a hook function, a target processing method is executed. The target processing method includes: when the second cached data includes the first type identifier, adding the second request identifier to the timestamp update request set. The target event is the event of receiving the second cached data returned by the server through the second interface.
6. A data processing apparatus, characterized in that, The device includes: The first acquisition module is used to acquire a timestamp update request set and a first request identifier of a first data request corresponding to a first interface when entering the interface of the target application including the target control. The first interface is the interface called by the target control. The timestamp update request set is used to record the request identifier of the data request corresponding to the timestamp update interface in the target application. The comparison module is used to compare the request identifiers included in the timestamp update request set with the first request identifier. The second acquisition module is used to acquire the first cached data corresponding to the first interface from the server through the first interface when the first request identifier exists in the timestamp update request set. The device further includes: The sending module is used to send a second data request to the server through a second interface; The receiving module is used to receive the second cached data returned by the server through the second interface; The module is used to add the second request identifier of the second data request to the timestamp update request set when the second cached data includes the first type identifier. The first type identifier is used to indicate that the second interface is a timestamp update interface. A recording module is used to record the mapping relationship between the data identifier of the second cached data and the second request identifier when the second cached data includes a first type identifier; The monitoring module is used to monitor the data of the target application; The comparison module is further configured to, upon receiving a deletion operation for any target cached data in the data, compare the data identifier included in the mapping relationship with the target data identifier of the target cached data. An adding module is used to add the request identifier corresponding to the target data identifier in the mapping relationship to the timestamp update request set when the target data identifier exists in the data identifiers included in the mapping relationship.
7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Page data management method, device and data server
CN105893607A
Data processing method and device, electronic equipment and storage medium
CN113806655A