A data processing method, apparatus, electronic device, and storage medium
By obtaining and verifying the attribute information of the target data and selecting the appropriate cache medium based on this information, the problem of insufficient storage space of local cache medium is solved, and the utilization rate of cache medium and the normal operation of the application is improved.
Patent Information
- Application Number
- CN201911387713.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-25
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2039-12-25
AI Technical Summary
As applications in electronic devices increase, data that needs to be cached also increases, resulting in insufficient storage space of local cache media, affecting the normal operation of the application.
By obtaining the first attribute information and the second attribute information of the target data to be cached, the validity of the data is verified, and an appropriate cache medium is selected according to the second attribute information for cache, avoiding invalid or unimportant data being cached into the local cache medium.
It effectively avoids the problem of insufficient storage space of local cache media, improves the utilization rate of cache media and data flexibility, and ensures the normal operation of the application.
Smart Images

Figure CN111124315B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a data processing method, apparatus, electronic device, and storage medium. Background Art
[0002] The local cache medium is a memory chip on the hard disk controller of an electronic device, which has a relatively fast access rate. It is a buffer between the internal storage of the hard disk and the external interface. Since the internal data transfer rate of the hard disk is different from the transfer rate of the external interface, the local cache medium plays a buffering role therein. Therefore, the local cache medium is usually used to cache the relevant data of the applications started in the electronic device. For example, if the started application is a browser application, the rendering parameters of the web page can be cached in the local storage medium, which is beneficial to quickly display the web page interface for the user. It is found in practice that as the applications in the electronic device increase, the data to be cached also increases, which easily leads to insufficient storage space of the local cache medium and affects the normal operation of the applications. Summary of the Invention
[0003] Embodiments of the present invention provide a data processing method, apparatus, electronic device, and storage medium, which can avoid the problem of insufficient storage space of the local cache medium and ensure the normal operation of the applications.
[0004] In a first aspect, an embodiment of the present invention provides a data processing method, which includes:
[0005] Obtain first attribute information and second attribute information of target data to be cached, where the first attribute information includes source information of the target data and / or the validity period of the target data, and the second attribute information includes the data type of the target data and / or key fields included in the target data;
[0006] Verify whether the target data is valid data according to the first attribute information;
[0007] If the target data is valid data, select a target cache medium for caching the target data according to the second attribute information, where the target cache medium includes a local cache medium or an external cache medium connected to the electronic device;
[0008] Cache the target data into the target cache medium.
[0009] In a second aspect, an embodiment of the present invention provides a data processing apparatus, including:
[0010] An acquisition unit, configured to acquire first attribute information and second attribute information of target data to be cached, where the first attribute information includes source information of the target data and / or a validity period of the target data, and the second attribute information includes a data type of the target data and / or key fields included in the target data;
[0011] A verification unit, configured to verify whether the target data is valid data according to the first attribute information;
[0012] A selection unit, configured to, if the target data is valid data, select a target cache medium for caching the target data according to the second attribute information, where the target cache medium includes a local cache medium or an external cache medium connected to the electronic device;
[0013] A caching unit, configured to cache the target data into the target cache medium.
[0014] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, where the processor and the memory are connected to each other. The memory is configured to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to execute the following steps:
[0015] Acquire first attribute information and second attribute information of target data to be cached, where the first attribute information includes source information of the target data and / or a validity period of the target data, and the second attribute information includes a data type of the target data and / or key fields included in the target data;
[0016] Verify whether the target data is valid data according to the first attribute information;
[0017] If the target data is valid data, select a target cache medium for caching the target data according to the second attribute information, where the target cache medium includes a local cache medium or an external cache medium connected to the electronic device;
[0018] Cache the target data into the target cache medium.
[0019] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, storing one or more instructions, where the one or more instructions are adapted to be loaded and executed by a processor to perform the following steps:
[0020] Obtain the first attribute information and the second attribute information of the target data to be cached, where the first attribute information includes the source information of the target data and / or the validity period of the target data, and the second attribute information includes the data type of the target data and / or the key fields included in the target data;
[0021] Verify whether the target data is valid data according to the first attribute information;
[0022] If the target data is valid data, select a target cache medium for caching the target data according to the second attribute information, where the target cache medium includes a local cache medium or an external cache medium connected to the electronic device;
[0023] Cache the target data into the target cache medium.
[0024] In the embodiments of the present invention, an electronic device can verify whether target data is valid data according to the first attribute information of the target data, which can avoid caching invalid data into the cache medium, save the storage space of the cache medium, and improve the utilization rate of the cache medium. Further, when the target data is valid data, select a target cache medium for caching the target data according to the second attribute information of the target data, and cache the target data into the target cache medium. It can avoid the problem that any data to be cached is cached into the local cache medium, resulting in insufficient storage space of the local cache medium. The cache medium can be flexibly selected through the second attribute information, improving the flexibility of caching data and ensuring the normal operation of the application programs in the electronic device. Description of the Drawings
[0025] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0026] Figure 1 is a schematic flowchart of a data processing method provided by an embodiment of the present invention;
[0027] Figure 2 is a schematic flowchart of another data processing method provided by an embodiment of the present invention;
[0028] Figure 3 is a schematic structural diagram of a data processing device provided by an embodiment of the present invention;
[0029] Figure 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed Embodiments
[0030] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0031] The embodiments of the present invention can be implemented by an electronic device, which can be a terminal device or a server. The terminal device can refer to a tablet computer, a portable personal computer, and so on. The server can be an independent server, or a server cluster composed of several servers, or a cloud computing center.
[0032] Please refer to Figure 1 , which is a schematic flowchart of a data processing method provided by an embodiment of the present invention. The method in the embodiment of the present invention can be executed by the above-mentioned electronic device. In this embodiment, the data processing method includes the following steps.
[0033] The embodiments of the present invention can be implemented by an electronic device, which can be a server or a terminal device. The terminal device can refer to a tablet computer, a portable personal computer, and so on. The server can be an independent server, or a server cluster composed of several servers, or a cloud computing center.
[0034] Please refer to Figure 1 , which is a schematic flowchart of a data processing method provided by an embodiment of the present invention. The method in the embodiment of the present invention can be executed by the above-mentioned electronic device. In this embodiment, the data processing method includes the following steps.
[0035] S101. Obtain first attribute information and second attribute information of target data to be cached. The first attribute information includes source information of the target data and / or the validity period of the target data, and the second attribute information includes the data type of the target data and / or key fields included in the target data.
[0036] The target data can be the data that needs to be cached. Specifically, the target data can be data related to an application running on an electronic device, or the target data can be temporary data sent from other devices to the electronic device. To cache the target data flexibly, the electronic device can obtain the first attribute information and the second attribute information of the target data. The first attribute information includes the source information of the target data and / or the validity period of the target data. The source information of the target data is used to indicate which device the target data comes from, that is, the source information includes the device identifier, and the device identifier includes the IP address, serial number, etc. of the device. Or, the source information of the target data is used to indicate which website the target data comes from, that is, the source information includes the website name or address. Or, the source information of the target data is used to indicate which application the target data belongs to, that is, the source information includes the identifier of the application. The validity period of the target data refers to the maximum period to ensure the validity of the target data. The target data is valid means that the target data can be used to achieve a certain function, that is, the target data is invalid means that it cannot be used to achieve a certain function. For example, the target data is a malicious virus, or the target data has been updated. The second attribute information includes the data type of the target data and / or the key fields included in the target data. The type of the target data includes at least one of text type, image type, and audio-video type, etc. The key fields included in the target data can refer to the fields that appear more than a preset number threshold in the historical data to be cached.
[0037] It should be noted that since the target data can be discarded when it is determined to be invalid data according to the first attribute information, that is, there is no need to obtain the second attribute information of the target data. Therefore, the second attribute information of the target data can be obtained after it is determined that the target data is valid data, which can save the resources consumed by the electronic device to obtain the second attribute information.
[0038] S102. Verify whether the target data is valid data according to the first attribute information. If the target data is invalid data, end this process; if the target data is valid data, execute step S103.
[0039] To reduce the caching pressure of the caching medium, the electronic device can verify whether the target data is valid data according to the first attribute information. If the target data is invalid data, it means that the target data cannot be used to achieve a certain function, then the target data is discarded; if the target data is valid data, it means that the target data can be used to achieve a certain function, then the target data can be cached.
[0040] In one embodiment, the first attribute information includes the validity period of the target data, and step S102 may include the following steps s11 to s13.
[0041] s11. Obtain the current system time of the electronic device.
[0042] s12. If the current system time of the electronic device exceeds the validity period of the target data, determine that the target data is invalid data.
[0043] s13. If the current system time of the electronic device is within the validity period of the target data, determine that the target data is valid data.
[0044] In steps s11 to s13, the electronic device can obtain the current system time of the electronic device. If the current system time of the electronic device exceeds the validity period of the target data, it indicates that the target data has expired. For example, if the target data has been updated, the target data is invalid data. If the current system time of the electronic device is within the validity period of the target data, it indicates that the target data has not expired, and thus determine that the target data is valid data. For example, if the validity period of the target data is from September 19, 2019 to September 23, 2019, and the current system time of the electronic device is September 18, 2019, that is, the current system time of the electronic device exceeds the validity period of the target data, then determine that the target data is invalid data. If the current system time of the electronic device is September 19, 2019, that is, the current system time of the electronic device is within the validity period of the target data, then determine that the target data is valid data.
[0045] In another embodiment, the first attribute information includes the source information of the target data, and step S102 may include the following steps s21 to s23.
[0046] s21. Determine whether the source information of the target data matches the preset source information, where the preset source information is the source information of the recorded valid data.
[0047] s22. If not, determine that the target data is invalid data.
[0048] s23. If so, determine that the target data is valid data.
[0049] In steps s21 to s23, the electronic device can determine whether the source data of the target data matches the preset source information. If not, it indicates that the target data comes from a device, network, or application program with relatively low security, that is, the target data may be malicious data. Therefore, determine that the target data is invalid data. If it matches, it indicates that the target data comes from a device, network, or application program with relatively high security. Therefore, determine that the target data is valid data.
[0050] S103. If the target data is valid data, select a target caching medium for caching the target data according to the second attribute information. The target caching medium includes a local caching medium or an external caching medium connected to the electronic device.
[0051] If the target data is valid data, the electronic device can select a target caching medium for caching the target data according to the second attribute information, which can avoid the problem that any data to be cached is cached in the local caching medium, resulting in insufficient storage space of the local caching medium. The caching medium can be flexibly selected through the second attribute information, improving the flexibility of caching data and ensuring the normal operation of the application programs in the electronic device. The local caching medium is a memory chip on the hard disk controller of the electronic device, with a relatively fast access rate and high security, but its storage space is relatively small, that is, the amount of data that can be stored is less. The external caching medium refers to caching middleware, which can also be called a secondary caching medium. The access rate of accessing data is slower, and its storage space is relatively large, that is, the amount of data that can be stored is relatively large. The external caching medium is caching middleware, with a slower access rate and relatively low security, but its storage space is relatively large, that is, the amount of data that can be stored is more. In one embodiment, step S103 may include the following steps s31 to s33.
[0052] s31. Determine the importance level of the target data according to the second attribute information.
[0053] s32. If the importance level of the target data is greater than the preset level threshold, determine the local caching medium as the target caching medium for caching the target data.
[0054] s33. If the importance level of the target data is less than or equal to the preset level threshold, determine the external caching medium as the target caching medium for caching the target data.
[0055] In steps s31 to s33, the electronic device can determine the importance level of the target data according to the second attribute information. If the importance level of the target data is greater than the preset level threshold, it indicates that the user has a relatively high requirement for the caching security of the target data and a relatively high requirement for the reading speed of the target data. Therefore, the local caching medium can be determined as the target caching medium for caching the target data. If the importance level of the target data is less than or equal to the preset level threshold, it indicates that the user has a relatively low requirement for the caching security of the target data and a relatively low requirement for the reading speed of the target data, then the external caching medium is determined as the target caching medium for caching the target data.
[0056] Optionally, the second attribute information includes the data type of the target data, and step s31 may include the following steps s41 to s44.
[0057] S41. Obtain the target number of times that data with a data type matching the data type of the target data is read from the data read log, where the data read log includes the number of times each piece of data cached in the local cache medium and the external cache medium is read.
[0058] S42. Statistically obtain the total number of times all data cached in the local cache medium and the external cache medium is read from the data read log.
[0059] S43. Calculate the ratio between the target number of times and the total number of times.
[0060] S44. Determine the importance level of the target data according to the ratio.
[0061] In steps S41 to S44, the electronic device can obtain the target number of times that data with a data type matching the data type of the target data is read from the data read log, and obtain the target number of times that data with a data type matching the data type of the target data is read from the data read log. And calculate the ratio between the target number of times and the total number of times, and determine the importance level of the target data according to the ratio. That is, the larger the ratio, the more times the target data is read, that is, the target data is a hot data, and the higher the importance level of the target data; that is, the smaller the ratio, the fewer times the target data is read, that is, the target data is a non - hot data, and the lower the importance level of the target data. In this way, data with a higher number of read times can be cached in the local cache medium, which can ensure the data read rate; and data with a lower number of read times can be cached in the external cache medium, which can relieve the storage pressure of the local cache medium.
[0062] In one embodiment, the attribute information includes the data type of the target data, and step S31 may include the following steps S51 to S54.
[0063] S51. Statistically obtain the update frequency of data of various data types from the data update log, and obtain the target update frequency of data with a data type matching the data type of the target data, where the data update log includes the update frequency of each piece of data cached in the local cache medium and the external cache medium.
[0064] S52. Calculate the average update frequency according to the update frequency of data of various data types.
[0065] S53. Calculate the difference between the target update frequency and the average update frequency.
[0066] S54. Determine the importance level of the target data according to the difference.
[0067] In steps S51 - S54, the electronic device can count the update frequencies of data of various data types from the data update log, and obtain the target update frequency of data whose data type matches that of the target data. The preset average algorithm is used to calculate the average update frequency of the update frequencies of data of various data types. The preset average algorithm can refer to algorithms such as the arithmetic average algorithm or the statistical average algorithm. Further, calculate the difference between the target update frequency and the average update frequency, and determine the importance level of the target data based on this difference. That is, the larger the difference, the higher the update frequency of the target data, which means the target data is more likely to become invalid, that is, the importance level of the target data is relatively low. The smaller the difference, the lower the update frequency of the target data, and the target data is not likely to become invalid, that is, the importance level of the target data is relatively high. In this way, data with a lower update frequency can be stored in the local cache medium, avoiding storing data that is likely to become invalid in the local cache medium, which can improve the utilization value of the local cache medium; data with a higher update frequency can be stored in the external cache medium, which can relieve the storage pressure on the local cache medium.
[0068] Optionally, the second attribute information includes the key fields included in the target data, and step S31 may include the following steps S61 - S62.
[0069] S61. Determine the sensitivity of the key fields in the target data according to the correspondence between the key fields and the sensitivities of the key fields.
[0070] S62. Determine the importance level of the target data according to the sensitivity of the key fields in the target data.
[0071] In steps S61 - S62, the electronic device can obtain the correspondence between the key fields and the sensitivities of the key fields, and determine the sensitivity of the key fields in the target data according to the correspondence between the key fields and the sensitivities of the key fields. Further, determine the importance level of the target data according to the sensitivity of the key fields in the target data. That is, the higher the sensitivity, the stronger the privacy of the target data, and the higher the importance level of the target data; the lower the sensitivity, the weaker the privacy of the target data, and the lower the importance level of the target data. In this way, data with strong privacy can be cached in the local cache medium, ensuring the security of data caching; and data with weak privacy can be cached in the external cache medium, relieving the storage pressure on the local cache medium.
[0072] S104. Cache the target data in the target cache medium.
[0073] The electronic device can cache the target data in the target cache medium. To facilitate subsequent search for the target data, the electronic device can cache the target data in the storage area corresponding to the data type of the target data in the target cache medium.
[0074] In the embodiments of the present invention, the electronic device can verify whether the target data is valid data according to the first attribute information of the target data, which can avoid caching invalid data in the cache medium, save the storage space of the cache medium, and improve the utilization rate of the cache medium. Further, when the target data is valid data, the target cache medium for caching the target data is selected according to the second attribute information of the target data, and the target data is cached in the target cache medium. It can avoid the problem that any data to be cached is cached in the local cache medium, resulting in insufficient storage space of the local cache medium. The cache medium can be flexibly selected through the second attribute information, improving the flexibility of caching data and ensuring the normal operation of the application programs in the electronic device.
[0075] Please refer to Figure 2 , which is a schematic flowchart of another data processing method provided by the embodiments of the present invention. The method in the embodiments of the present invention can be executed by the above-mentioned electronic device. In this embodiment, the data processing method includes the following steps.
[0076] S201. Obtain the first attribute information and the second attribute information of the target data to be cached. The first attribute information includes the source information of the target data and / or the validity period of the target data, and the second attribute information includes the data type of the target data and / or the key fields included in the target data.
[0077] S202. Verify whether the target data is valid data according to the first attribute information. If the target data is invalid data, end this process; if the target data is valid data, execute step S103.
[0078] S203. If the target data is valid data, select the target cache medium for caching the target data according to the second attribute information. The target cache medium includes the local cache medium or an external cache medium connected to the electronic device.
[0079] S204. Cache the target data in the target cache medium.
[0080] In the embodiments of the present invention, the explanations of steps S201 - S204 can be referred to Figure 1 the explanations of steps S101 - S104 in, and the repeated parts will not be elaborated.
[0081] In one embodiment, step S204 includes: preprocessing the target data to obtain the preprocessed target data, and caching the preprocessed target data in a target cache medium.
[0082] To save storage space and improve the utilization rate of the cache medium, the electronic device can preprocess the target data to obtain the preprocessed target data. The preprocessing may refer to data filtering or format processing. Further, the preprocessed target data is cached in a target cache medium.
[0083] Optionally, the preprocessing includes data filtering, which can filter out duplicate data in the target data. The preprocessing of the target data specifically includes: dividing the target data into multiple data segments, where the multiple data segments at least include a first data segment and a second data segment, and calculating the similarity between every two data segments. If the similarity between the first data segment and the second data segment is less than or equal to a preset similarity threshold, it indicates that the first data segment and the second data segment are not duplicate data segments, and then the first data segment and the second data segment are retained. If the similarity between the first data segment and the second data segment is greater than the preset similarity threshold, it indicates that the first data segment and the second data segment are duplicate data segments, and then the second data segment can be deleted to obtain the preprocessed target data, which can save the storage space of the target cache medium.
[0084] Optionally, the preprocessing includes format processing, which can cache the target data in a unified data format. The preprocessing of the target data specifically includes: obtaining the format of the data in the target cache medium, and performing format processing on the target data using the format of the data in the target cache medium to obtain the preprocessed target data, that is, the format of the preprocessed target data is the same as the format of the data in the target cache medium, which is beneficial to the normalized management of the data in the target cache medium and is beneficial to quickly reading the data from the target cache medium.
[0085] S205. Receive a read request for the target data, where the read request carries second attribute information of the target data.
[0086] S206. Determine the cache medium for caching the target data according to the second attribute information of the target data.
[0087] S207. Read the target data from the determined cache medium.
[0088] In steps S205 - S207, the electronic device can receive a read request for the target data. The read request carries second attribute information of the target data. The read request can be initiated by the electronic device itself or by other devices. Further, the cache medium for the target data can be determined according to the second attribute information of the target data, and the target data can be queried from the determined cache medium, which can improve the efficiency of reading the target data and save the resources required for finding the target data.
[0089] In one embodiment, the method further includes the following steps S71 - S73:
[0090] S71. Obtain a data read queue, which includes multiple data read requests, and each data read request carries second attribute information of the data to be read.
[0091] S72. Perform a merging process on the multiple data read requests according to the second attribute information to obtain a merged data read request.
[0092] S73. Process the merged data read request to read the data.
[0093] In steps S71 - S73, the electronic device can obtain a data read queue, which includes multiple data read requests, and each data read request carries second attribute information of the data to be read. Since data with the same second attribute information is cached in the same cache medium, the electronic device can perform a merging process on the multiple data read requests according to the second attribute information to obtain a merged data read request, and process the merged data read request to read the data. That is, the data read requests corresponding to data with the same second attribute information are merged, which can reduce the number of times of reading data from the cache medium, extend the lifespan of the cache medium, and improve the efficiency of data reading.
[0094] Optionally, the electronic device may include a batch data read interface and a single data processing interface. The batch data read interface can process multiple data read requests simultaneously and consumes more resources; the single data processing interface can process a single data read request and consumes less resources. To flexibly process data read tasks and improve data read efficiency, step S73 may specifically include: if the number of requests in the merged data read request is greater than a preset threshold, use the batch data read interface to process the merged data read request; if the number of requests in the merged data read request is less than or equal to the preset threshold, use the single data read interface to process the merged data read request.
[0095] In an embodiment of the present invention, an electronic device can verify whether target data is valid data according to the first attribute information of the target data, which can avoid caching invalid data in a cache medium, save the storage space of the cache medium, and improve the utilization rate of the cache medium. Further, when the target data is valid data, a target cache medium for caching the target data is selected according to the second attribute information of the target data, and the target data is cached in the target cache medium. It can avoid the problem that any data to be cached is cached in the local cache medium, resulting in insufficient storage space of the local cache medium. The cache medium can be flexibly selected through the second attribute information, improving the flexibility of caching data and ensuring the normal operation of the application programs in the electronic device.
[0096] Please refer to Figure 3 , which is a schematic structural diagram of a data processing device provided by an embodiment of the present invention. The device in the embodiment of the present invention can be arranged in the above-mentioned electronic device. In this embodiment, the data processing device includes:
[0097] An acquisition unit 301, configured to acquire the first attribute information and the second attribute information of target data to be cached, where the first attribute information includes the source information of the target data and / or the validity period of the target data, and the second attribute information includes the data type of the target data and / or the key fields included in the target data.
[0098] A verification unit 302, configured to verify whether the target data is valid data according to the first attribute information.
[0099] A selection unit 303, configured to, if the target data is valid data, select a target cache medium for caching the target data according to the second attribute information, where the target cache medium includes a local cache medium or an external cache medium connected to the electronic device.
[0100] A cache unit 304, configured to cache the target data in the target cache medium.
[0101] Optionally, the selection unit 303 is specifically configured to determine the importance level of the target data according to the second attribute information; if the importance level of the target data is greater than a preset level threshold, determine the local cache medium as the target cache medium for caching the target data; if the importance level of the target data is less than or equal to the preset level threshold, determine the external cache medium as the target cache medium for caching the target data.
[0102] Optionally, the second attribute information includes the data type of the target data. The selection unit 303 is specifically configured to obtain the target number of times that the data whose data type matches the data type of the target data is read from the data read log, where the data read log includes the number of times each piece of data cached in the local cache medium and the external cache medium is read; count the total number of times all the data cached in the local cache medium and the external cache medium is read from the data read log; calculate the ratio between the target number of times and the total number of times; and determine the importance level of the target data according to the ratio.
[0103] Optionally, the second attribute information includes the data type of the target data. The selection unit 303 counts the update frequency of each data type from the data update log and obtains the target update frequency of the data whose data type matches the data type of the target data, where the data update log includes the update frequency of each piece of data cached in the local cache medium and the external cache medium; calculates the average update frequency according to the update frequency of each data type; calculates the difference between the target update frequency and the average update frequency; and determines the importance level of the target data according to the difference.
[0104] Optionally, the second attribute information includes the key fields included in the target data. The selection unit 303 is specifically configured to determine the sensitivity of the key fields in the target data according to the correspondence between the key fields and the sensitivity of the key fields; and determine the importance level of the target data according to the sensitivity of the key fields in the target data.
[0105] Optionally, the first attribute information includes the validity period of the target data. The verification unit 302 is specifically configured to obtain the current system time of the electronic device; if the current system time of the electronic device exceeds the validity period of the target data, determine that the target data is invalid data; if the current system time of the electronic device is within the validity period of the target data, determine that the target data is valid data.
[0106] Optionally, the first attribute information includes the source information of the target data. The verification unit 302 is specifically configured to determine whether the source information of the target data matches the preset source information, where the preset source information is the source information of the recorded valid data; if not, determine that the target data is invalid data; if so, determine that the target data is valid data.
[0107] Optionally, a reading unit 305 is configured to receive a reading request for the target data, where the reading request carries second attribute information of the target data; determine a cache medium for caching the target data according to the second attribute information of the target data; and read the target data from the determined cache medium.
[0108] Optionally, the reading unit 305 is configured to obtain a data reading queue, where the data reading queue includes a plurality of data reading requests, and each data reading request carries second attribute information of data to be read; perform a merging process on the plurality of data reading requests according to the second attribute information to obtain a merged data reading request; and process the merged data reading request to read the data to be read.
[0109] In an embodiment of the present invention, an electronic device may verify whether the target data is valid data according to the first attribute information of the target data, which can avoid caching invalid data into the cache medium, save the storage space of the cache medium, and improve the utilization rate of the cache medium. Further, when the target data is valid data, a target cache medium for caching the target data is selected according to the second attribute information of the target data, and the target data is cached into the target cache medium. It can avoid the problem that any data to be cached is cached into the local cache medium, resulting in insufficient storage space of the local cache medium. The cache medium can be flexibly selected through the second attribute information, improving the flexibility of caching data and ensuring the normal operation of the application program in the electronic device.
[0110] Please refer to Figure 4 , which is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. As shown in the figure, the electronic device in this embodiment may include: one or more processors 401; one or more input devices 402, one or more output devices 403, and a memory 404. The above-mentioned processors 401, input devices 402, output devices 403, and memory 404 are connected through a bus 405.
[0111] The processor 401 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, 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, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0112] The input device 402 may include a touchpad, a fingerprint sensor (for collecting the fingerprint information and the direction information of the fingerprint of the user), a microphone, etc., and the output device 403 may include a display (such as an LCD), a speaker, etc.
[0113] The memory 404 may include a read-only memory and a random access memory, and provide instructions and data to the processor 401. A part of the memory 404 may further include a non-volatile random access memory. The memory 404 is used to store a computer program, and the computer program includes program instructions. The processor 401 is used to execute the program instructions stored in the memory 404 to execute a data processing method, that is, to perform the following operations:
[0114] Obtain first attribute information and second attribute information of target data to be cached, where the first attribute information includes source information of the target data and / or the validity period of the target data, and the second attribute information includes the data type of the target data and / or key fields included in the target data;
[0115] Verify whether the target data is valid data according to the first attribute information;
[0116] If the target data is valid data, select a target cache medium for caching the target data according to the second attribute information, where the target cache medium includes a local cache medium or an external cache medium connected to the electronic device;
[0117] Cache the target data into the target cache medium.
[0118] Optionally, the processor calls an instruction to perform the following steps:
[0119] Determine the importance level of the target data according to the second attribute information;
[0120] If the importance level of the target data is greater than a preset level threshold, determine the local cache medium as the target cache medium for caching the target data;
[0121] If the importance level of the target data is less than or equal to the preset level threshold, determine the external cache medium as the target cache medium for caching the target data.
[0122] Optionally, the processor calls an instruction to perform the following steps:
[0123] Obtain the target number of times that data with a data type matching the data type of the target data is read from a data reading log, where the data reading log includes the number of times each piece of data cached in the local cache medium and the external cache medium is read;
[0124] Count the total number of times all the data cached in the local cache medium and the external cache medium are read from the data read log;
[0125] Calculate the ratio between the target number of times and the total number of times;
[0126] Determine the importance level of the target data according to the ratio.
[0127] Optionally, the processor invokes an instruction to perform the following steps:
[0128] Count the update frequencies of data of various data types from the data update log, and obtain the target update frequency of data whose data type matches the data type of the target data. The data update log includes the update frequency of each piece of data cached in the local cache medium and the external cache medium;
[0129] Calculate the average update frequency according to the update frequencies of data of various data types;
[0130] Calculate the difference between the target update frequency and the average update frequency;
[0131] Determine the importance level of the target data according to the difference.
[0132] Optionally, the processor invokes an instruction to perform the following steps:
[0133] Determine the sensitivity of the keyword fields in the target data according to the correspondence between the keyword fields and the sensitivity of the keyword fields;
[0134] Determine the importance level of the target data according to the sensitivity of the keyword fields in the target data.
[0135] Optionally, the processor invokes an instruction to perform the following steps:
[0136] Obtain the current system time of the electronic device;
[0137] If the current system time of the electronic device exceeds the validity period of the target data, determine that the target data is invalid data;
[0138] If the current system time of the electronic device is within the validity period of the target data, determine that the target data is valid data.
[0139] Optionally, the processor invokes an instruction to perform the following steps:
[0140] Determine whether the source information of the target data matches the preset source information, where the preset source information is the source information of the recorded valid data;
[0141] If not, determine that the target data is invalid data;
[0142] If it matches, determine that the target data is valid data.
[0143] Optionally, the processor calls an instruction to perform the following steps:
[0144] Receive a read request for the target data, where the read request carries the second attribute information of the target data;
[0145] Determine the cache medium for caching the target data according to the second attribute information of the target data;
[0146] Read the target data from the determined cache medium.
[0147] Optionally, the processor calls an instruction to perform the following steps:
[0148] Obtain a data read queue, where the data read queue includes multiple data read requests, and each data read request carries the second attribute information of the data to be read;
[0149] Perform a merging process on the multiple data read requests according to the second attribute information to obtain a merged data read request;
[0150] Process the merged data read request to read the data to be read.
[0151] In the embodiments of the present invention, the electronic device can verify whether the target data is valid data according to the first attribute information of the target data, which can avoid caching invalid data into the cache medium, save the storage space of the cache medium, and improve the utilization rate of the cache medium. Further, when the target data is valid data, select the target cache medium for caching the target data according to the second attribute information of the target data, and cache the target data into the target cache medium. It can avoid the problem that any data to be cached is cached into the local cache medium, resulting in insufficient storage space of the local cache medium. The cache medium can be flexibly selected through the second attribute information, improving the flexibility of caching data and ensuring the normal operation of the application programs in the electronic device.
[0152] In the embodiments of the present invention, the processor 401, input device 402, and output device 403 described can implement the implementation manners described in the first embodiment and the second embodiment of the data processing method provided by the embodiments of the present invention, and can also implement the implementation manner of the electronic device described in the embodiments of the present invention, which will not be elaborated herein.
[0153] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, the data processing method shown in the embodiments of the present invention is implemented. Figure 1 and Figure 2 the data processing method shown in the embodiments.
[0154] The computer-readable storage medium may be an internal storage unit of the electronic device described in any of the foregoing embodiments, such as the hard disk or memory of the control device. The computer-readable storage medium may also be an external storage device of the control device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device. Further, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the control device. The computer-readable storage medium is used to store the computer program and other programs and data required by the control device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0155] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the control device and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be repeated here.
[0156] In several embodiments provided in the present application, it should be understood that the disclosed control device and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0157] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A data processing method, applied to an electronic device, characterized in that, Including: Obtain the first attribute information and the second attribute information of the target data to be cached, where the first attribute information includes the source information of the target data, and the second attribute information includes the data type of the target data; Determine whether the source information of the target data matches the preset source information, where the preset source information is the source information of the recorded valid data; If it matches, determine that the target data is valid data; If the target data is valid data, then count the update frequencies of the data of various data types from the data update log, and obtain the target update frequency of the data whose data type matches the data type of the target data. The data update log includes the update frequency of each piece of data cached in the local cache medium and the external cache medium; Calculate the average update frequency according to the update frequencies of the data of various data types; calculate the difference between the target update frequency and the average update frequency; Determine the importance level of the target data according to the difference; there is a negative correlation between the difference and the importance level, and there is a positive correlation between the difference and the target update frequency; If the importance level of the target data is greater than the preset level threshold, then determine the local cache medium as the target cache medium for caching the target data; If the importance level of the target data is less than or equal to the preset level threshold, then determine the external cache medium as the target cache medium for caching the target data; Cache the target data into the target cache medium; Obtain a data reading queue, where the data reading queue includes multiple data reading requests, and each data reading request carries the second attribute information of the data to be read; Perform a merging process on the multiple data reading requests according to the second attribute information to obtain a merged data reading request; If the number of requests in the merged data reading request is greater than the preset threshold, then process the merged data reading request using a batch data reading interface; If the number of requests in the merged data reading request is less than or equal to the preset threshold, then process the merged data reading request using a single data reading interface.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the target number of times the data whose data type matches the data type of the target data is read from the data reading log. The data reading log includes the number of times each piece of data cached in the local cache medium and the external cache medium is read; Count the total number of times all the data cached in the local cache medium and the external cache medium is read from the data reading log; Calculate the ratio between the target number of times and the total number of times; Determine the importance level of the target data according to the ratio.
3. The method according to any one of claims 1-2, characterized in that, The first attribute information includes the validity period of the target data, and the method further includes: Obtain the current system time of the electronic device; If the current system time of the electronic device exceeds the validity period of the target data, then determine that the target data is invalid data; If the current system time of the electronic device is within the validity period of the target data, then determine that the target data is valid data.
4. A data processing device, characterized in that, Including: An acquisition unit, configured to acquire first attribute information and second attribute information of target data to be cached, where the first attribute information includes source information of the target data, and the second attribute information includes a data type of the target data; A verification unit, configured to determine whether the source information of the target data matches preset source information, where the preset source information is source information of recorded valid data; If they match, determining that the target data is valid data; A selection unit, configured to, if the target data is valid data, count the update frequencies of data of various data types from a data update log, and obtain a target update frequency of data whose data type matches the data type of the target data, where the data update log includes the update frequencies of each piece of data cached in a local cache medium and an external cache medium; Calculating an average update frequency according to the update frequencies of data of various data types; calculating a difference between the target update frequency and the average update frequency; Determining an importance level of the target data according to the difference; there is a negative correlation between the difference and the importance level, and there is a positive correlation between the difference and the target update frequency; if the importance level of the target data is greater than a preset level threshold, determining the local cache medium as a target cache medium for caching the target data; If the importance level of the target data is less than or equal to the preset level threshold, determining the external cache medium as a target cache medium for caching the target data; A caching unit, configured to cache the target data into the target cache medium; A reading unit, configured to obtain a data reading queue, where the data reading queue includes a plurality of data reading requests, and each data reading request carries second attribute information of data to be read; Performing a merging process on the plurality of data reading requests according to the second attribute information to obtain a merged data reading request; If the number of requests in the merged data reading request is greater than a preset threshold, processing the merged data reading request by using a batch data reading interface; If the number of requests in the merged data reading request is less than or equal to the preset threshold, processing the merged data reading request by using a single data reading interface.
5. An electronic device, characterized in that, Including: A processor and a memory, where the processor and the memory are connected to each other. The memory is configured to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to execute the method according to any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, and the at least one instruction is suitable for being loaded and executed by a processor to execute the method according to any one of claims 1-3.
Citation Information
Patent Citations
Method and device for reading external memory
CN101206624A
Method, device and system for data storage
CN104461935A
Storage management method for application data and network management system
CN104657435A
Webpage resource caching method and device, storage medium and electronic device
CN110020290A