Data storage method and device, electronic equipment and storage medium
By obtaining the storage time and query times of the initial data, and determining and updating the target data storage time, the problem of inability to reasonably configure the data storage time in the prior art is solved, and reasonable adjustment of data storage time and resource conservation are achieved.
Patent Information
- Application Number
- CN202310981253.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
The prior art cannot configure reasonable data storage time for each piece of data, resulting in wasted system storage resources.
By obtaining the initial data storage time of the initial data and the number of data queries for the initial data partitions at different time, the target data storage time is determined, and the storage time of the initial data is updated, so as to reasonably configure the storage time according to the data query frequency.
A reasonable data storage time configuration based on data query frequency is realized, which shortens the data storage time and saves data storage resources.
Smart Images

Figure CN119441211A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a data storage method, device, electronic device and storage medium. Background Art
[0002] Data storage time refers to the length of time that data is retained on a system or platform. The length of data storage time can vary depending on various factors, such as business needs, compliance requirements, security considerations, etc. For data with lower value, the data storage time can be shortened to avoid wasting system storage resources.
[0003] In the related art, for the massive amount of data stored in the system, it is impossible to configure a reasonable data storage time for each piece of data in a targeted manner. Summary of the invention
[0004] The present disclosure proposes a data storage method, device, electronic device, storage medium and computer program product, aiming to solve the technical problems in the related art at least to a certain extent.
[0005] The first aspect of the present disclosure proposes a data storage method, including: obtaining an initial data storage time of initial data, and the number of data queries for the initial data in different time partitions, and determining a target data storage time based on the number of data queries for different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time, and then updating the initial data storage time of the initial data to the target data storage time.
[0006] The second aspect embodiment of the present disclosure proposes a data storage device, including: an acquisition module, used to acquire the initial data storage time of initial data, and the number of data queries for the initial data in different time partitions; a determination module, used to determine the target data storage time according to the number of data queries for different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time; and an update module, used to update the initial data storage time of the initial data to the target data storage time.
[0007] The third aspect of the present disclosure provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a data storage method.
[0008] A fourth aspect of the present disclosure provides a computer-readable storage medium. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a data storage method.
[0009] A fifth aspect of the present disclosure provides a computer program product, including a computer program, wherein the computer program is executed by a processor and a data storage method is performed.
[0010] The data storage method, device, electronic device, storage medium and computer program product proposed in this embodiment have at least the following beneficial effects: by obtaining the initial data storage time of the initial data and the number of data queries of the initial data in different time partitions, and determining the target data storage time according to the number of data queries and the initial data storage time in different time partitions, wherein the target data storage time is less than or equal to the initial data storage time, and then updating the initial data storage time of the initial data to the target data storage time, so that the data storage time can be reasonably configured for the corresponding initial data based on the number of data queries of the initial data in different time partitions, so that the storage time of the initial data can be shortened to a certain extent, thereby effectively saving data storage resources. Furthermore, the technical problem that it is impossible to configure a reasonable data storage time for each piece of data in a targeted manner in the prior art is solved.
[0011] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description or learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The above and / or additional aspects and advantages of the present disclosure will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0013] Figure 1 is a flowchart of a data storage method according to a first embodiment of the present disclosure;
[0014] Figure 2 is a flow chart of a data storage method according to a second embodiment of the present disclosure;
[0015] Figure 3 is a schematic diagram of a process for determining a target data storage time proposed in an embodiment of the present disclosure;
[0016] Figure 4 is a block diagram of a data storage device according to the present disclosure;
[0017] Figure 5 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0018] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present disclosure, and are not to be construed as limitations of the present disclosure. On the contrary, the embodiments of the present disclosure include all changes, modifications, and equivalents that fall within the spirit and connotation of the appended claims.
[0019] It should be noted that the executor of the data storage method of this embodiment may be a data storage device, which may be implemented by software and / or hardware, and which may be configured in an electronic device, which may include but is not limited to a terminal, a server, etc.
[0020] It should be noted that the process of obtaining, storing, using, and processing information in the disclosed technical solution complies with the relevant provisions of national laws and regulations and does not violate public order and good morals.
[0021] Figure 1 is a flow chart of a data storage method according to the first embodiment of the present disclosure, such as Figure 1 As shown, the method includes:
[0022] S101: Acquire the initial data storage time of initial data and the number of data queries of the initial data in different time partitions.
[0023] Among them, the initial data can be unprocessed data obtained at the initial stage of the data storage method. The initial data can be data stored in a cloud storage platform, data stored in a database, or the initial data can be data stored in a distributed data storage system, without limitation.
[0024] In the disclosed embodiment, one or more data tables may be obtained from a distributed data storage system (eg, Hadoop Distributed File System (HDFS)), and the data in the one or more data tables may be used as initial data.
[0025] That is to say, in the embodiments of the present disclosure, the client can initiate an HTTP REST request to the distributed data storage system, call the interface to transmit data table identification information (for example, the data table name, which is not limited to this) to the distributed data storage system, so as to obtain all the data in the data table corresponding to the data table identification information as the initial data. Alternatively, the distributed data storage system can periodically traverse all the data tables in the system to determine the data in one or more data tables as the initial data, which is not limited to this.
[0026] The initial data storage time is used to describe the storage time of the corresponding initial data initially set in the storage medium, that is, the initial data will be deleted from the corresponding storage medium after the corresponding initial data storage time.
[0027] Among them, time partitions refer to multiple time ranges obtained by dividing according to time periods such as years, months, weeks, and days.
[0028] The number of data queries for the initial data in different time partitions refers to the number of times the initial data is queried in different time partitions.
[0029] In some embodiments, the number of data queries for the initial data in different time partitions can be obtained by monitoring the corresponding storage system and recording the data query time of the initial data when it is monitored that the storage system receives a data call request for the corresponding initial data. Then, the number of data query times recorded at different data query times can be divided into the corresponding time partitions, and there is no limitation on this.
[0030] In other embodiments, obtaining the number of data queries for the initial data in different time partitions may also be done by querying the Elastic Search search engine for the number of data queries for the initial data in different time partitions that is pre-saved in the search engine, that is, the number of data queries for the initial data in different time partitions may be obtained by indexing from the Elastic Search search engine using the data identification information of the initial data, and there is no limitation to this.
[0031] S102: Determine a target data storage time according to the number of data queries and the initial data storage time of different time partitions.
[0032] The target data storage time is less than or equal to the initial data storage time.
[0033] That is, after obtaining the data query times of the initial data in different time partitions, the embodiments of the present disclosure may adjust the initial data storage time according to the data query times of the different time partitions to determine the target data storage time.
[0034] It is understandable that when initial data is stored in any storage medium, a corresponding initial data storage time will be set for the initial data. The initial data storage time is usually long. However, the storage space of the storage medium is relatively limited. For initial data with low usage value (for example, low data call frequency), its long-term storage in the storage medium will occupy a large storage space, thereby causing a waste of data storage resources. That is, when new data needs to be stored in the storage medium, the storage space of the storage medium may be full, resulting in the inability to store new data.
[0035] Therefore, in some embodiments, the target data storage time is determined based on the number of data queries in different time partitions and the initial data storage time. The corresponding data query number threshold may be determined for the initial data in a preset time partition, and then, when the number of data queries in the time partition is less than the data query number threshold, the initial data storage time may be shortened and the shortened initial data storage time may be used as the target data storage time. When the number of data queries in the time partition is greater than or equal to the data query number threshold, the initial data storage time may be used as the target data storage time.
[0036] Optionally, in some embodiments, the target data storage time is determined based on the number of data queries in different time partitions and the initial data storage time. The corresponding data query times can be sorted according to the chronological order of the time partitions to obtain a query number sequence, and candidate data storage times corresponding to the initial data storage time are obtained, wherein the candidate data storage time is less than the initial data storage time, and then the target data storage time is determined based on the query number sequence, the initial data storage time and the candidate data storage time.
[0037] That is to say, in the embodiment of the present disclosure, the corresponding data query times may be sorted according to the chronological order of the time partitions to obtain a query time sequence.
[0038] For example, different time partitions and the number of data queries for different time partitions can be, for example: [(2023.01.01, 0), (2023.01.02, 0), (2023.01.03, 10), (2023.01.04, 20), ...], so that the corresponding data query times can be sorted according to the order of time partitions to obtain a query number sequence of: [0, 0, 10, 20].
[0039] The candidate data storage time may be a data storage time pre-configured for the initial data in conjunction with the initial data storage time. The candidate data storage time may be adaptively configured in combination with the data storage cost requirement in an actual business scenario. For example, if the data storage cost requirement is to reduce the original data storage cost by 50%, 50% of the initial data storage time may be used as the candidate data storage time. Thus, examples of the initial data storage time and the candidate data storage time may be shown in Table 1:
[0040] Table 1
[0041] Initial data storage time Candidate data storage time 365 180 180 90 90 60 60 30 30 15 15 7 7 3
[0042] In the disclosed embodiment, the target data storage time is determined according to the query number sequence, the initial data storage time and the candidate data storage time. The target data storage time of the initial data may be determined based on the data query number variation rule described by the data query number sequence. For example, when the query number variation rule described by the data query number sequence indicates that the use value of the initial data gradually decreases, the candidate data storage time may be used as the target data storage time. Conversely, when the query number variation rule described by the data query number sequence indicates that the use value of the initial data gradually increases, the initial data storage time may be used as the target data storage time. Thus, the target data storage time may be determined from the preset candidate data storage times in combination with the data query number variation rule described by the data query number sequence. Since the candidate data storage time is pre-set, it can be ensured that when matching the target data storage time for each initial data, the same storage time configuration specification can be used.
[0043] S103: Update the initial data storage time of the initial data to the target data storage time.
[0044] After determining the target data storage time according to the number of data queries and the initial data storage time of different time partitions, the embodiment of the present disclosure can update the initial data storage time of the initial data to the target data storage time.
[0045] Therefore, the data storage method of the embodiment of the present invention can shorten the initial data storage time of initial data with lower usage value (for example, lower data query times) by determining the target data storage time according to the number of data queries and the initial data storage time in different time partitions, so that the storage system can delete the initial data earlier, thereby effectively saving data storage resources.
[0046] In this embodiment, the target data storage time is determined by obtaining the initial data storage time of the initial data and the number of data queries for the initial data in different time partitions, and according to the number of data queries for different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time, and then the initial data storage time of the initial data is updated to the target data storage time. Thus, based on the number of data queries for the initial data in different time partitions, the data storage time can be reasonably configured for the corresponding initial data, thereby shortening the storage time of the initial data to a certain extent, thereby effectively saving data storage resources.
[0047] Figure 2 is a flow chart of a data storage method according to a second embodiment of the present disclosure, such as Figure 2As shown, the method includes:
[0048] S201: Acquire the initial data storage time of the initial data and the number of data queries of the initial data in different time partitions.
[0049] S202: Sort the corresponding data query times according to the chronological order of the time partitions to obtain a query time sequence.
[0050] S203: Acquire a candidate data storage time corresponding to the initial data storage time, wherein the candidate data storage time is smaller than the initial data storage time.
[0051] The specific description of S201 - S203 can be found in the above embodiment, which will not be repeated here.
[0052] S204: Determine the first number of consecutive data query times that is less than or equal to a first preset number that appears in the query times sequence for the first time.
[0053] Among them, the first preset number of times can be adaptively configured according to the data storage requirements in the actual business scenario without any restriction.
[0054] The first number of consecutive data query times that is less than or equal to the first preset number that appears for the first time in the query number sequence is the first number.
[0055] For example, assuming that the data query number sequence is [0, 0, 10, 20, 0, 0, 100, 150], the first preset number can be, for example, 0 times. Thus, the number of data query times that first appears in the aforementioned data query number sequence and is continuously 0 (2 times) can be taken as the first number.
[0056] S205: Determine the time difference between the initial data storage time and the candidate data storage time.
[0057] In the embodiment of the present disclosure, the difference between the initial data storage time and the candidate data storage time is the time difference.
[0058] In combination with the example in Table 1 above, assuming that the initial data storage time is 7 days, and the candidate data storage time corresponding to the initial data storage time is 3 days, then 7 and 3 can be subtracted, and the resulting 4 days can be used as the time difference, and there is no restriction on this.
[0059] S206: When the first number is greater than or equal to the time difference of the first preset multiple, the candidate data storage time is used as the target data storage time.
[0060] The first preset multiple may be adaptively configured according to data storage requirements in actual business scenarios, and the first preset multiple may be, for example, 50%, without limitation.
[0061] That is to say, in the embodiment of the present disclosure, the time difference between the first quantity determined above and the first preset multiple may be compared, and when the first quantity is greater than or equal to the time difference of the first preset multiple (i.e., continuousZeroDay≥50%*(oldDLC-newDLC), where continuousZeroDay is the first quantity and (oldDLC-newDLC) is the time difference), the candidate data storage time may be used as the target data storage time.
[0062] In the embodiment of the present disclosure, since the first number of data query times that is continuously less than or equal to the first preset number of times appears in the query number sequence for the first time is determined, when the time difference of the first number is greater than or equal to the first preset multiple, it can be preliminarily determined that the use value of the initial data is low (i.e., it has not been queried within a continuous time period), and the initial data storage time of the initial data is revised to the candidate time storage time, which can effectively shorten the data storage time of the initial data and effectively save data storage resources.
[0063] S207: When the first number is smaller than the time difference of the first preset multiple, determine a second number of data query times in the query times sequence that is smaller than or equal to the first preset number.
[0064] The number of data query times in the query times sequence that is less than or equal to the first preset number is the second number.
[0065] That is to say, in the embodiment of the present disclosure, the time difference between the first number determined above and the first preset multiple may be compared, and when the first number is smaller than the time difference of the first preset multiple (i.e., continuousZeroDay<50%*(oldDLC-newDLC)), a second number of data query times in the query time sequence that is smaller than or equal to the first preset number is determined.
[0066] For example, assuming that the data query number sequence is [0, 0, 10, 20, 0, 0, 100, 150], the first preset number can be, for example, 0 times. Therefore, the number of data query times in the aforementioned data query number sequence that is less than or equal to the first preset number (4 times) can be taken as the second number.
[0067] S208: When the second number is greater than or equal to the time difference of the second preset multiple, the candidate data storage time is used as the target data storage time.
[0068] Among them, the second preset multiple is greater than the first preset multiple, and the second preset multiple can be adaptively configured according to the data storage requirements in the actual business scenario. The second preset multiple can be, for example, 60%, and there is no limitation on this.
[0069] In the embodiment of the present disclosure, after determining a second number of data query times in a query number sequence that is less than or equal to a first preset number of times, the time difference between the second number and a second preset multiple may be compared, and when the second number is greater than or equal to the time difference between the second preset multiple (i.e., sumZeroDay≥60%*(oldDLC-newDLC), where sumZeroDay is the second number and (oldDLC-newDLC) is the time difference), the candidate data storage time is used as the target data storage time.
[0070] In the embodiment of the present disclosure, since the second number of data query times less than or equal to the first preset number in the query number sequence is determined, the data query times less than or equal to the first preset number in the query number sequence can be filtered on a global basis of all time partitions. Compared with the first number determined above, the second number makes another secondary screening of a looser screening dimension, so that when the first judgment corresponding to the first number is not satisfied, the judgment strategy can be appropriately relaxed, thereby ensuring the saving of data storage resources compared to the first judgment corresponding to the first number. For the storage medium storing the initial data, by determining the second number and executing the judgment strategy corresponding to the second number, the storage time of the initial data can be shortened when the judgment strategy corresponding to the second number is satisfied, thereby ensuring that the storage space of the storage medium is sufficient and that new data can be stored in the storage medium.
[0071] S209: When the second number is smaller than the time difference of the second preset multiple, determine a third number of data query times in the query number sequence that is smaller than or equal to the second preset number.
[0072] Among them, the second preset number of times is greater than the first preset number of times, and the second preset number of times can be adaptively configured according to the data storage requirements in the actual business scenario, and there is no restriction on this.
[0073] Among them, the number of data query times in the query number sequence that is less than or equal to the second preset number is the third number.
[0074] That is to say, in the embodiment of the present disclosure, the time difference between the second number determined above and the second preset multiple may be compared, and when the second number is smaller than the time difference of the second preset multiple (i.e. sumZeroDay<60%*(oldDLC-newDLC)), a third number of data query times that is smaller than or equal to the second preset number is determined.
[0075] For example, assuming that the data query number sequence is [0, 0, 10, 20, 0, 0, 100, 150], the second preset number can be, for example, 10 times. Therefore, the number of data query times in the aforementioned data query number sequence that is less than or equal to the second preset number (5 times) can be taken as the third number.
[0076] S210: When the third number is greater than or equal to the time difference of the third preset multiple, the candidate data storage time is used as the target data storage time.
[0077] Among them, the third preset multiple is the same as or different from the second preset multiple. The third preset multiple can be adaptively configured according to the data storage requirements in the actual business scenario. The third preset multiple can be, for example, 30%, and there is no limitation on this.
[0078] In an embodiment of the present disclosure, after determining a third number of data query times in a query number sequence that is less than or equal to a second preset number of times, the third number and the time difference of a third preset multiple may be compared, and when the third number is greater than or equal to the time difference of a third preset multiple (i.e., sumLess10QueryDay≥30%*(oldDLC-newDLC), where sumLess10QueryDay is the third number and (oldDLC-newDLC) is the time difference), the candidate data storage time is used as the target data storage time.
[0079] In the embodiment of the present disclosure, since the third number of data query times in the query time sequence that is less than or equal to the second preset number is determined, the data query times in the query time sequence that are less than or equal to the second preset number can be filtered on a global basis of all time partitions. Compared with the second number determined above, the third number makes another three-time screening of a looser screening dimension, so that when the secondary judgment corresponding to the second number is not satisfied, the judgment strategy can be appropriately relaxed, thereby saving data storage resources compared to the secondary judgment corresponding to the second number. For the storage medium that stores the initial data, by determining the third number and executing the judgment strategy corresponding to the third number, the storage time of the initial data can be shortened when the judgment strategy corresponding to the third number is satisfied, thereby ensuring that the storage space of the storage medium is sufficient and that new data can be stored in the storage medium.
[0080] S211: When the third number is smaller than the time difference value of the third preset multiple, determine a fourth number of data query times in the query times sequence that is smaller than or equal to the third preset number.
[0081] Among them, the third preset number of times is greater than the second preset number of times, and the third preset number of times can be adaptively configured according to the data storage requirements in the actual business scenario, and there is no restriction on this.
[0082] Among them, the number of data query times in the query number sequence that is less than or equal to the third preset number is the fourth number.
[0083] That is to say, in the embodiment of the present disclosure, the time difference between the third number determined above and the third preset multiple may be compared, and when the third number is less than the time difference of the third preset multiple (i.e. sumLess10QueryDay<30%*(oldDLC-newDLC)), a fourth number of data query times that is less than or equal to the third preset number is determined.
[0084] For example, assuming that the data query number sequence is [0, 0, 10, 20, 0, 0, 100, 150], the third preset number can be, for example, 100 times. Therefore, the number of data query times in the aforementioned data query number sequence that is less than or equal to the third preset number (6 times) can be taken as the fourth number.
[0085] S212: When the fourth number is greater than or equal to the time difference of a fourth preset multiple, the candidate data storage time is used as the target data storage time.
[0086] Among them, the fourth preset multiple is greater than the third preset multiple, and the fourth preset multiple can be adaptively configured according to the data storage requirements in the actual business scenario. The fourth preset multiple can be, for example, 80%, and there is no limitation on this.
[0087] In an embodiment of the present disclosure, after determining the fourth number of data query times in the query number sequence that is less than or equal to the third preset number, the time difference between the fourth number and the fourth preset multiple may be compared, and when the fourth number is greater than or equal to the time difference of the fourth preset multiple (i.e., sumLess100QueryDay≥80%*(oldDLC-newDLC), where sumLess100QueryDay is the fourth number and (oldDLC-newDLC) is the time difference), the candidate data storage time is used as the target data storage time.
[0088] In the embodiment of the present disclosure, since the fourth number of data query times less than or equal to the third preset number in the query number sequence is determined, the data query times less than or equal to the third preset number in the query number sequence can be filtered on a global basis of all time partitions. Compared with the third number determined above, the fourth number makes four screenings of another looser screening dimension, so that when the three judgments corresponding to the third number are not satisfied, the judgment strategy can be appropriately relaxed, thereby saving data storage resources compared to the three judgments corresponding to the third number. For the storage medium storing the initial data, by determining the fourth number and executing the judgment strategy corresponding to the fourth number, the storage time of the initial data can be shortened when the judgment strategy corresponding to the fourth number is satisfied, thereby ensuring that the storage space of the storage medium is sufficient and that new data can be stored in the storage medium.
[0089] S213: When the fourth number is smaller than the time difference of the fourth preset multiple, the initial data storage time is used as the target data storage time.
[0090] That is to say, in the embodiment of the present disclosure, the time difference between the aforementioned fourth number and the fourth preset multiple may be compared, and when the fourth number is less than the time difference of the fourth preset multiple (i.e., sumLess100QueryDay<80%*(oldDLC-newDLC)), the initial data storage time may be used as the target data storage time.
[0091] That is to say, in the embodiments of the present disclosure, see Figure 3 , Figure 3It is a schematic diagram of the process of determining the target data storage time proposed in an embodiment of the present disclosure, that is, it can be that in the initial stage, the first time that a first number of data query times that are consecutively less than or equal to a first preset number of times and a time difference of a first preset multiple appear in a query number sequence, and it is judged whether the first number is greater than or equal to the time difference of the first preset multiple, if the first number is greater than or equal to the time difference of the first preset multiple, the candidate data storage time is used as the target data storage time, if the first number is less than the time difference of the first preset multiple, then determine a second number of data query times that are less than or equal to the first preset number in the query number sequence, and judge whether the second number is greater than or equal to the time difference of the second preset multiple, if the second number is greater than or equal to the time difference of the second preset multiple, then use the candidate data storage time as the target data storage time, and in When the second number is less than the time difference of the second preset multiple, determine the third number of data query times in the query number sequence that is less than or equal to the second preset number, and judge whether the third number is greater than or equal to the time difference of the third preset multiple, and when the third number is greater than or equal to the time difference of the third preset multiple, use the candidate data storage time as the target data storage time, when the third number is less than the time difference of the third preset multiple, determine the fourth number of data query times in the query number sequence that is less than or equal to the third preset number, and judge whether the fourth number is greater than or equal to the time difference of the fourth preset multiple, and when the fourth number is greater than or equal to the time difference of the fourth preset multiple, use the candidate data storage time as the target data storage time, and when the fourth number is less than the time difference of the fourth preset multiple, use the initial data storage time as the target data storage time.
[0092] Therefore, in the embodiment of the present disclosure, by gradually determining the first number, the second number, the third number and the fourth number from the data query frequency sequence, and gradually performing corresponding judgment strategies for the first number, the second number, the third number and the fourth number, and because the determination conditions of the first number, the second number, the third number and the fourth number are gradually relaxed, it is possible to effectively save data storage resources while ensuring the data usage needs in actual business scenarios, and for storage media with limited storage space, by executing the first step-by-step judgment strategy based on the first number, the second number, the third number and the fourth number, it can be ensured that the storage space of the storage medium can be released to the maximum extent, thereby ensuring that new data can be stored in the storage medium.
[0093] S214: Update the initial data storage time of the initial data to the target data storage time.
[0094] The specific description of S214 can be found in the above embodiment, which will not be repeated here.
[0095] In an embodiment of the present disclosure, initial data is obtained, wherein the initial data has a corresponding initial data storage time, and the number of data queries of the initial data in different time partitions is obtained, and then the corresponding data query times are sorted according to the time sequence of the time partitions to obtain a query number sequence, and a candidate data storage time corresponding to the initial data storage time is obtained, wherein the candidate data storage time is less than the initial data storage time, and then a first number of data query times that are less than or equal to a first preset number of times that appear continuously for the first time in the query number sequence is determined, and a time difference between the initial data storage time and the candidate data storage time is determined, and then, when the first number is greater than or equal to a first preset multiple of the time difference, the candidate data storage time is used as a target data storage time, and when the first number is less than the first preset multiple of the time difference, a second number of data query times that are less than or equal to the first preset number in the query number sequence is determined, and then when the second number is greater than or equal to the second preset multiple of the time difference, the candidate data storage time is used as the target data storage time, and when the second number is less than the second preset multiple of the time difference, a third number of data query times that are less than or equal to the second preset number in the query number sequence is determined, and then when the third number is greater than or equal to the third preset multiple of the time difference In the case of a time difference between the first and second numbers, the candidate data storage time is used as the target data storage time; in the case of a time difference between the third number and the third preset multiple, a fourth number of data query times less than or equal to the third preset multiple in the query times sequence is determined; in the case of a time difference between the fourth number and the fourth preset multiple, the candidate data storage time is used as the target data storage time; in the case of a time difference between the fourth number and the fourth preset multiple, the initial data storage time is used as the target data storage time, and the initial data storage time of the initial data is updated to the target data storage time, by gradually determining the first number, the second number, the third number and the fourth number from the data query times sequence, and gradually performing the corresponding judgment strategies for the first number, the second number, the third number and the fourth number, and because the determination conditions for the first number, the second number, the third number and the fourth number are gradually relaxed, it is possible to effectively save data storage resources while ensuring the data usage needs in actual business scenarios, and for a storage medium with limited storage space, by executing the first judgment strategy based on the first number, the second number, the third number and the fourth number, it is possible to ensure that the storage space of the storage medium can be released to the maximum extent, thereby ensuring that new data can be stored in the storage medium.
[0096] Figure 4 is a block diagram of a data storage device according to the present disclosure, such as Figure 4 As shown, the data storage device 40 comprises:
[0097] An acquisition module 401 is used to acquire the initial data storage time of the initial data and the number of data queries of the initial data in different time partitions;
[0098] Determination module 402, used to determine the target data storage time according to the number of data queries in different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time;
[0099] The updating module 403 is used to update the initial data storage time of the initial data to the target data storage time.
[0100] In some embodiments of the present disclosure, the determination module 402 is further configured to:
[0101] Sort the corresponding data query times according to the chronological order of the time partitions to obtain a query time sequence;
[0102] Acquire a candidate data storage time corresponding to the initial data storage time, wherein the candidate data storage time is less than the initial data storage time;
[0103] The target data storage time is determined according to the query number sequence, the initial data storage time and the candidate data storage time.
[0104] In some embodiments of the present disclosure, the determination module 402 is further configured to:
[0105] Determine the first occurrence of a first number of consecutive data query times less than or equal to a first preset number in the query times sequence;
[0106] Determine the time difference between the initial data storage time and the candidate data storage time;
[0107] When the first number is greater than or equal to the time difference of the first preset multiple, the candidate data storage time is used as the target data storage time.
[0108] In some embodiments of the present disclosure, the determination module 402 is further configured to:
[0109] After determining the time difference between the initial data storage time and the candidate data storage time, if the first number is less than the time difference of the first preset multiple, determining a second number of data query times in the query number sequence that is less than or equal to the first preset number;
[0110] In the case that the second number is greater than or equal to the time difference of a second preset multiple, the candidate data storage time is used as the target data storage time, wherein the second preset multiple is greater than the first preset multiple.
[0111] In some embodiments of the present disclosure, the determination module 402 is further configured to:
[0112] After determining a second number of data query times in the query times sequence that is less than or equal to the first preset number, when the second number is less than the time difference value of the second preset multiple, determining a third number of data query times in the query times sequence that is less than or equal to the second preset number, wherein the second preset number is greater than the first preset number;
[0113] In the case that the third number is greater than or equal to the time difference of the third preset multiple, the candidate data storage time is used as the target data storage time, wherein the third preset multiple is the same as or different from the second preset multiple.
[0114] In some embodiments of the present disclosure, the determination module 402 is further configured to:
[0115] After determining a third number of data query times in the query times sequence that is less than or equal to the second preset number, if the third number is less than the time difference value of the third preset multiple, determining a fourth number of data query times in the query times sequence that is less than or equal to the third preset number, wherein the third preset number is greater than the second preset number;
[0116] In a case where the fourth number is greater than or equal to the time difference of a fourth preset multiple, the candidate data storage time is used as the target data storage time, wherein the fourth preset multiple is greater than the third preset multiple.
[0117] In some embodiments of the present disclosure, the determination module 402 is further configured to:
[0118] After determining a fourth number of data query times less than or equal to the third preset number in the query times sequence, when the fourth number is less than the time difference of a fourth preset multiple, the initial data storage time is used as the target data storage time.
[0119] In this embodiment, the target data storage time is determined by obtaining the initial data storage time of the initial data and the number of data queries for the initial data in different time partitions, and according to the number of data queries for different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time, and then the initial data storage time of the initial data is updated to the target data storage time. Thus, based on the number of data queries for the initial data in different time partitions, the data storage time can be reasonably configured for the corresponding initial data, thereby shortening the storage time of the initial data to a certain extent, thereby effectively saving data storage resources.
[0120] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a computer-readable storage medium, and a computer program product.
[0121] Figure 5 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown.
[0122] Figure 5 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0123] like Figure 5 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a memory 28, and a bus 18 that connects various system components (including the memory 28 and the processing unit 16).
[0124] The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnection (PCI) bus.
[0125] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0126] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 Not shown, often called a "hard drive").
[0127] although Figure 5Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (hereinafter referred to as: CD-ROM), a digital versatile disc read only memory (hereinafter referred to as: DVD-ROM) or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.
[0128] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described in the present disclosure.
[0129] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), may also communicate with one or more devices that enable the human body to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. In addition, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0130] The processing unit 16 executes various functional applications and parameter information determination by running the program stored in the memory 28, such as implementing the business data storage method mentioned in the above embodiment, or implementing the business data acquisition method mentioned in the above embodiment.
[0131] It should be noted that, in the description of the present disclosure, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present disclosure, unless otherwise specified, the meaning of "plurality" is two or more.
[0132] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.
[0133] It should be understood that the various parts of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0134] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0135] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0136] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0137] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0138] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present disclosure.
Claims
1. A data storage method, characterized in that: The method comprises: Obtaining the initial data storage time of the initial data and the number of data queries of the initial data in different time partitions; Determine a target data storage time according to the number of data queries for the different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time; The initial data storage time of the initial data is updated to the target data storage time.
2. The method according to claim 1, characterized in that The determining the target data storage time according to the number of data queries for the different time partitions and the initial data storage time includes: Sorting the corresponding data query times according to the time sequence of the time partitions to obtain a query time sequence; Acquire a candidate data storage time corresponding to the initial data storage time, wherein the candidate data storage time is less than the initial data storage time; The target data storage time is determined according to the query number sequence, the initial data storage time and the candidate data storage time.
3. The method according to claim 2, characterized in that The determining the target data storage time according to the query number sequence, the initial data storage time and the candidate data storage time includes: Determine the first occurrence of a first number of consecutive data query times less than or equal to a first preset number in the query times sequence; Determine a time difference between the initial data storage time and the candidate data storage time; In a case where the first number is greater than or equal to a first preset multiple of the time difference, the candidate data storage time is used as the target data storage time.
4. The method according to claim 3, characterized in that After determining the time difference between the initial data storage time and the candidate data storage time, the following steps are included: In the case where the first number is less than the time difference value of the first preset multiple, determining a second number of data query times in the query times sequence that is less than or equal to the first preset number; In the case that the second number is greater than or equal to the time difference of a second preset multiple, the candidate data storage time is used as the target data storage time, wherein the second preset multiple is greater than the first preset multiple.
5. The method according to claim 4, characterized in that After determining a second number of data query times in the query times sequence that is less than or equal to the first preset number, the method further includes: In the case where the second number is less than the time difference of the second preset multiple, determining a third number of data query times in the query times sequence that is less than or equal to the second preset number, wherein the second preset number is greater than the first preset number; In a case where the third number is greater than or equal to a third preset multiple of the time difference, the candidate data storage time is used as the target data storage time.
6. The method according to claim 5, characterized in that After determining a third number of data query times in the query times sequence that is less than or equal to a second preset number, the method further includes: In the case where the third number is less than the time difference of the third preset multiple, determining a fourth number of data query times in the query times sequence that is less than or equal to the third preset number, wherein the third preset number is greater than the second preset number; In a case where the fourth number is greater than or equal to the time difference of a fourth preset multiple, the candidate data storage time is used as the target data storage time, wherein the fourth preset multiple is greater than the third preset multiple.
7. The method according to claim 6, characterized in that After determining a fourth number of data query times in the query times sequence that is less than or equal to a third preset number, the method further includes: In a case where the fourth number is smaller than the time difference of the fourth preset multiple, the initial data storage time is used as the target data storage time.
8. A data storage device, characterized in that: The device comprises: An acquisition module, used to acquire the initial data storage time of the initial data and the number of data queries of the initial data in different time partitions; A determination module, configured to determine a target data storage time according to the number of data queries for the different time partitions and the initial data storage time, wherein the target data storage time is less than or equal to the initial data storage time; An updating module is used to update the initial data storage time of the initial data to the target data storage time.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 7.