A method, device, storage medium and computer device for updating cached data
By comparing and updating the data of file blocks in memory, the problem of inconsistency between cached memory and non-cached memory data is solved, and the consistent update of data is achieved.
Patent Information
- Application Number
- CN201910650945.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-18
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2039-07-18
AI Technical Summary
After the data provider places data from the non-cache memory into the cache memory, as the data in the non-cache memory increases, the data in the cache memory is inconsistent with the data in the non-cache memory, resulting in the cache memory not being updated.
By obtaining the data request, the file block sequence number and the file block group sequence number are determined, and the data amount of file blocks in the first type of memory and the second type of memory is compared. When the data amount is inconsistent, the file blocks in the second type of memory are updated to be consistent with the file blocks in the first type of memory.
Ensure that the data in cached memory is consistent with the data in non-cache memory, solving the problem that cached memory cannot be updated.
Smart Images

Figure CN112241376B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data storage, and particularly to a method and apparatus for updating cached data, a storage medium, and a computer device. Background Art
[0002] To facilitate a data requester to obtain data, a data provider usually puts the data requested by the data requester from a non-cacheable memory into a cacheable memory. For example, the data provider puts the hot segment data of a certain video from a non-cacheable memory into a cacheable memory, so that after the data requester requests the hot segment data, the data provider can quickly send the hot segment data to the data requester.
[0003] However, after the data in the non-cacheable memory is put into the cacheable memory, if the data in the non-cacheable memory is increased, it will cause the data in the cacheable memory to be inconsistent with the data in the non-cacheable memory. For example, after the data provider puts the hot segment data of a certain video from a non-cacheable memory into a cacheable memory, as the hot segment data of the video in the non-cacheable memory increases, the hot segment data in the cacheable memory does not increase, resulting in the problem that the hot segment data in the cacheable memory is inconsistent with the hot segment data in the non-cacheable memory. Summary of the Invention
[0004] In view of the above problems, the present invention provides a method and apparatus for updating cached data, a storage medium, and a computer device that overcome or at least partially solve the above problems, and the technical solutions are as follows:
[0005] A method for updating cached data includes:
[0006] Obtaining a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file;
[0007] Determining, according to the file identifier, the starting position, and the offset of the first file in the first data request, the sequence numbers of at least one file block stored in a first type of memory and matching the data requested by the first data request;
[0008] Determining the data amount of each file block in the first type of memory;
[0009] Determining, according to the sequence numbers of the file blocks, the sequence number of the file block group where the data requested by the first data request is located;
[0010] For any group of file blocks with a determined serial number: According to the file identifier, determine the data volume of this group of file blocks in the second type of memory. When the data volume of this group of file blocks in the second type of memory is less than the preset data volume, determine the data volume of each file block in this group of file blocks in the second type of memory. For any file block in this group of file blocks: According to the serial number of this file block, determine whether the data volume of this file block in the first type of memory is the same as the data volume of this file block in the second type of memory. If they are different, update the file block saved in the second type of memory to the file block saved in the first type of memory.
[0011] Optionally, the determining the serial number of the group of file blocks where the data requested by the first data request is located according to the serial number of the file block includes:
[0012] For any file block among the at least one file block: According to the serial number of this file block, determine the serial number of the group of file blocks to which this file block belongs, and determine the serial number of the group of file blocks where part or all of the data requested by the first data request is located as the serial number of this group of file blocks.
[0013] Optionally, the updating the file block saved in the second type of memory to the file block saved in the first type of memory includes:
[0014] Copy the data corresponding to the file block saved in the first type of memory to the file block saved in the second type of memory.
[0015] Optionally, the preset data volume is the sum of the maximum data volumes that all file blocks in the group of file blocks can correspond to.
[0016] Optionally, the number of file blocks included in each group of file blocks is the same. The determining the serial number of the group of file blocks where the data requested by the first data request is located according to the serial number of the file block includes:
[0017] For each of the file blocks: Subtract the starting serial number of the file block from the serial number of this file block, divide the result by the number of file blocks included in the group of file blocks to obtain a quotient, round down the quotient, and determine the rounded-down result as the serial number of the group of file blocks to which this file block belongs.
[0018] A cache data update device includes: a data request obtaining unit, a file block serial number determining unit, a file block data volume determining unit, a file block group serial number determining unit, and a file block updating unit.
[0019] The data request obtaining unit is configured to obtain a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file.
[0020] The file block serial number determining unit is configured to determine the serial numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request according to the file identifier, starting position, and offset of the first file in the first data request;
[0021] The file block data volume determining unit is configured to determine the data volume of each file block in the first type of memory;
[0022] The file block group serial number determining unit is configured to determine the serial number of the file block group where the data requested by the first data request is located according to the serial number of the file block;
[0023] The file block updating unit is configured to, for any file block group with a determined serial number: determine the data volume of the file block group in the second type of memory according to the file identifier, and when the data volume of the file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in the second type of memory in the file block group. For any file block in the file block group: determine whether the data volume of the file block in the first type of memory is the same as the data volume of the file block in the second type of memory according to the serial number of the file block. If they are different, update the file block stored in the second type of memory to the file block stored in the first type of memory.
[0024] Optionally, the file block group serial number determining unit is specifically configured to, for any file block in the at least one file block: determine the serial number of the file block group to which the file block belongs according to the serial number of the file block, and determine the serial number of the file block group where part or all of the data requested by the first data request is located as the serial number of the file block group.
[0025] Optionally, the file block updating unit is specifically configured to copy the data corresponding to the file block stored in the first type of memory to the file block stored in the second type of memory.
[0026] A storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, the cache data update method as described in any one of the above is implemented.
[0027] A computer device includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, at least the following steps are implemented:
[0028] Obtain a first data request, where the first data request carries the file identifier, starting position, and offset of the first file;
[0029] Determine the sequence numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request according to the file identifier, start position, and offset of the first file in the first data request;
[0030] Determine the data volume of each file block in the first type of memory;
[0031] Determine the sequence number of the file block group where the data requested by the first data request is located according to the sequence number of the file block;
[0032] For any file block group with a determined sequence number: Determine the data volume of this file block group in the second type of memory according to the file identifier. When the data volume of this file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in this file block group in the second type of memory. For any file block in this file block group: Determine whether the data volume of this file block in the first type of memory is the same as the data volume of this file block in the second type of memory according to the sequence number of this file block. If they are different, update the file block stored in the second type of memory to the file block stored in the first type of memory.
[0033] With the above technical solution, a method, device, storage medium, and computer device for updating cached data provided by the present invention can obtain a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file; determine, according to the file identifier, the starting position, and the offset of the first file in the first data request, the sequence numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request; determine the data volume of each file block in the first type of memory; determine the sequence number of the file block group where the data requested by the first data request is located according to the sequence number of the file block; for any determined sequence number of file block group: determine the data volume of the file block group in the second type of memory according to the file identifier, and when the data volume of the file block group in the second type of memory is less than a preset data volume, determine the data volume of each file block in the second type of memory in the file block group, and for any file block in the file block group: determine whether the data volume of the file block in the first type of memory is the same as the data volume of the file block in the second type of memory according to the sequence number of the file block, and if not, update the file block stored in the second type of memory to the file block stored in the first type of memory. Because the present invention adopts the technical means that the data volumes of the file blocks with the same sequence numbers in the first type of memory and the second type of memory and the sequence numbers of the file block groups are also the same, it overcomes the technical problem that the cached memory cannot be updated, and further achieves the technical effect of keeping the data in the cached memory consistent with the data in the non-cached memory.
[0034] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other objects, features, and advantages of the present invention more obvious and understandable, the specific embodiments of the present invention are specifically described below. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0036] Figure 1 shows a schematic flowchart of a method for updating cached data provided by an embodiment of the present invention;
[0037] Figure 2 shows a schematic explanatory diagram of a sequence number allocation method for a file block provided by an embodiment of the present invention;
[0038] Figure 3Shows an explanatory schematic diagram of a serial number allocation method for a file block group provided by an embodiment of the present invention;
[0039] Figure 4 Shows a schematic flowchart of another cache data update method provided by an embodiment of the present invention;
[0040] Figure 5 Shows an explanatory schematic diagram of the data volume of a file block group in a first type of memory and the data volume of the file block group in a second type of memory provided by an embodiment of the present invention;
[0041] Figure 6 Shows a schematic structural diagram of a cache data update device provided by an embodiment of the present invention. Detailed implementation manners
[0042] Hereinafter, exemplary embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0043] As Figure 1 shown, a cache data update method provided by an embodiment of the present invention may include:
[0044] S100. Obtain a first data request, where the first data request carries a file identifier, a start position, and an offset of a first file;
[0045] Specifically, the identifier of the first file may be a characteristic identifier that distinguishes the first file from other files. For example, the identifier of the first file may be characteristic identifier A, and the storage location of the first file can be determined in a memory storing multiple files through characteristic identifier A. The data requested by the first data request can be determined through the start position and offset of the first file. For example, assuming that the first file is a video file, it can be determined through the start position and offset that the first data request requests the video data within the first time period of the video file.
[0046] S200. Determine the serial numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request according to the file identifier, the start position, and the offset of the first file in the first data request;
[0047] Specifically, in the embodiments of the present invention, the first file can be divided into multiple file blocks, and the maximum data volume corresponding to each file block is the same. For example, if the data volume of the first file is 50 MB and the maximum data volume corresponding to each file block is 4 MB, then the first file can be divided into 13 file blocks. Among these 13 file blocks, 12 file blocks have a data volume of 4 MB, and 1 file block has a data volume of 2 MB. The maximum data volume corresponding to each file block can be set according to actual needs, and the present invention does not make further limitations here. In the embodiments of the present invention, sequence numbers can be assigned to each file block in a preset first order. The result of assigning sequence numbers to the file blocks divided from the first file in the present invention can be as Figure 2 shown. The first file is divided into 16 file blocks. In the embodiments of the present invention, these 16 file blocks can be respectively assigned sequence numbers 0, 1, 2,......, 15. In this case, if the data corresponding to the file block with sequence number 5 is at the starting position of the first file in the first data request, and the data corresponding to the file block with sequence number 10 is at the position after adding the offset to the starting position, then it can be determined that the data requested by the first data request is the data in the file blocks with sequence numbers 5 to 10. (For the convenience of description, in the following description of the present invention specification, the file block + sequence number form is used to represent the file block with this sequence number. For example: file block 5 represents the file block with a sequence number of 5.)
[0048] The first type of memory can include multiple first type storage disks. Each first type storage disk can have one or more disk blocks, and the storage spaces of the disk blocks in the first type storage disk can be the same. Among them, the storage space of the disk blocks in the first type storage disk is the same as the maximum data volume corresponding to the file block. Each disk block in the first type of memory can store a file block. The first type of memory can be a non-cache memory. The non-cache memory can be a mechanical hard disk, a hybrid hard disk, etc., and the embodiments of the present invention do not make limitations here. The first type of memory can be communicatively connected to the index server. In the embodiments of the present invention, the sequence numbers of at least one file block that matches the data requested by the first data request can be recorded in the index server. During subsequent use, in the embodiments of the present invention, the sequence numbers of at least one file block that matches the data requested by the first data request can be determined in the index server.
[0049] S300. Determine the data volume of each file block in the first type of memory;
[0050] Specifically, the data volume corresponding to each file block of the first file can be recorded in an index server communicatively connected to the first type of memory. Although the maximum data volume that each file block can correspond to is the same, the actual data volume corresponding to each file block can be different. For example, the maximum data volume that each file block can correspond to is 8 MB, where the data volume corresponding to file block A in these file blocks can be 8 MB, and the data volume corresponding to file block B can be 4 MB. By recording the actual data volume corresponding to the file blocks in the first type of memory in the index server, the present invention can directly determine the data volume of each file block in the first type of memory in the index server.
[0051] S400. Determine the serial number of the file block group where the data requested by the first data request is located according to the serial number of the file block.
[0052] Embodiments of the present invention can group multiple file blocks obtained by dividing the first file. Specifically, embodiments of the present invention can divide the multiple file blocks into one or more file block groups according to a preset quantity, and record the relationship between the file blocks included in the file block group and the file block group. At the same time, embodiments of the present invention can assign serial numbers to each file block group in a preset second order. For the sake of easy understanding, based on this, an example is given in combination with... Figure 2 on the basis of Figure 3 : If every 4 file blocks form a file block group, then serial numbers 0,..., 3 are assigned to each file block group. If it is determined that the data requested by the first data request is the data in file blocks 5 to 10, then it is determined that the serial numbers of the file block groups where the data requested by the first data request is located are 1 and 2 (for the sake of easy explanation, in the following description of the present invention specification, the file block group + serial number is used to represent the file block group with this serial number. For example, file block group 0 represents the file block group with the serial number of 0).
[0053] At the same time, embodiments of the present invention can record the serial numbers of each file block group in the index server. During subsequent use, embodiments of the present invention can determine the serial number of the file block group where the data requested by the first data request is located in the index server according to the serial number of the file block.
[0054] Optionally, as Figure 4 shown, another method for updating cached data provided by embodiments of the present invention, step S400 can be specifically:
[0055] S410. For any file block in the at least one file block: According to the serial number of the file block, determine the serial number of the file block group to which the file block belongs, and determine the serial number of the file block group where part or all of the data requested by the first data request is located as the serial number of the file block group.
[0056] For example, if file block group 0 includes file blocks 0, 1, and 2, file block group 1 includes file blocks 3 and 4, and file block group 2 includes file block 5. If the data requested by the first data request is data in file blocks 0 to 4, it can be determined that the data requested by the first data request is in file block group 0 and file block group 1; if the data requested by the first data request is data in file blocks 2 to 5, it can be determined that the data requested by the first data request is in file block group 0, file block group 1, and file block group 2.
[0057] Optionally, in another method for updating cached data provided in an embodiment of the present invention, the number of file blocks included in each file block group may be the same, and step S400 may be specifically: for each of the file blocks: subtract the starting sequence number of the file block from the sequence number of the file block, divide the result by the number of file blocks included in the file block group to obtain a quotient, round down the quotient, and determine the rounded-down result as the sequence number of the file block group to which the file block belongs.
[0058] For ease of understanding, here in combination with Figure 3 it is described as follows: If it is determined that the data requested by the first data request is data in file blocks 5 to 10, then the value obtained by subtracting the sequence number of file block 0 from the sequence number of file block 5 is 5, and the number of file blocks included in the file block group is 4. After dividing the value 5 obtained by subtracting the sequence number of file block 0 from the sequence number of file block 5 by the number of file blocks included in the file block group 4, the quotient is rounded down to 1, so the file block group to which file block 5 belongs is file block group 1. Similarly, the file block groups to which file blocks 6 and 7 belong are file block group 1, and the file block groups to which file blocks 8, 9, and 10 belong are file block group 2.
[0059] S500. For any file block group with a determined sequence number: Determine the data volume of this file block group in the second type of memory according to the file identifier. When the data volume of this file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in this file block group in the second type of memory. For any file block in this file block group: Determine whether the data volume of this file block in the first type of memory is the same as the data volume of this file block in the second type of memory according to the sequence number of this file block. If they are different, update the file block saved in the second type of memory to the file block saved in the first type of memory.
[0060] Specifically, through the file identifier, the embodiments of the present invention can determine the storage location of the first file in the second type of memory, and then determine the data volume of the file block group according to the determined serial number of the file block group. It should be noted that the data volume of the file block group with the same serial number in the first type of memory and the second type of memory may be the same or different. For the sake of easy understanding, an example is given here in combination with Figure 5 as follows: In Figure 5 , the shaded part represents the data corresponding to the file blocks in the file block group, and the blank part is the storage space for the data that the file blocks in the file block group can still correspond to. The data volume of file block group 1 in both the first type of memory and the second type of memory is 4MB, but the data volume of file block group 2 in the first type of memory is 3MB, and the data volume of the file block group in the second type of memory is 2MB. This is because the data added to the first file is first added to file block group 2 in the first type of memory. Therefore, the data volume of file block group 2 in the first type of memory is the data volume after the data added to the first file, while file block group 2 in the second type of memory has not been updated yet. Therefore, the data volume of file block group 2 in the second type of memory is still the data volume before the data added to the first file. So, it may cause the data volume of the file block group with the same serial number in the first type of memory and the second type of memory to be different. Thus, if data is directly obtained from the second type of memory according to the first data request, the data obtained may not be the latest data. Therefore, the embodiments of the present invention can compare the data volume of the file block group in the second type of memory with the data volume in the second type of memory to determine whether the data of the file block group in the second type of memory is the latest data, so that the data obtained from the second type of memory is the latest data.
[0061] The second type of memory may include multiple second type storage disks. Each second type storage disk may have one or more disk blocks. The storage spaces of the disk blocks in the second type of storage disk may be the same. Among them, the storage space of the disk blocks in the second type of storage disk is the same as the maximum data volume that a file block can correspond to. Each disk block in the second type of memory can store a file block.
[0062] It should be noted that the embodiments of the present invention can group the disk blocks in the second type of memory. Specifically, the embodiments of the present invention can divide at least one disk block in each second type of memory into a disk block group. Among them, the disk block groups to which the disk blocks in the same second type of memory belong can be the same or different. The positions of the disk blocks included in the same disk block group in the second type of memory are fixed. For the sake of easy understanding, an example is given here: If a certain disk block group includes disk block Q, disk block W, disk block E, and disk block R, and the positions of disk block Q and disk block W in a second type of memory are the first and the third respectively, then the positions of disk block E and disk block R in another second type of memory are also the first and the third (that is, disk block E is in the first and disk block R is in the third, or, disk block E is in the third and disk block R is in the first); If the positions of disk block Q, disk block W, and disk block E in a second type of memory are the first, the third, and the fourth respectively, then disk block R can be in any one of the positions of the first, the third, and the fourth in another second type of memory. In an alternative embodiment of the present invention, a file block group can be stored in a disk block group of the second type of memory.
[0063] The second type of memory can be a caching memory, and the caching memory can be a solid-state drive, which is not limited in the present invention. The second type of memory can be communicatively connected to a cache server, and the cache server can be communicatively connected to an index server. The embodiments of the present invention can record the sequence numbers of at least one file block matching the data requested by the first data request, the sequence numbers of each file block group, the data amounts of each file block in the second type of memory, and the data amounts of each file block group in the second type of memory in the cache server. During subsequent use, the embodiments of the present invention can determine the data amount of a file block group in the second type of memory in the cache server according to the sequence number of the file block group.
[0064] After determining the data amount of a certain file block group in the second type of memory, the embodiments of the present invention can compare the data amount of the file block group in the second type of memory with a preset data amount. The preset data amount can be a pre-judgment threshold for determining that the data amount of the file block group in the second type of memory is different from the data amount of the file block group in the first type of memory. Since the increase of the data of the first file in the embodiments of the present invention can first be performed on the file blocks in which the actual data amount corresponding to the file block in the multiple file blocks divided by the first file does not reach the maximum data amount that the file block can correspond to, the preset data amount can be the sum of the maximum data amounts that all file blocks in the file block group can correspond to. When the data amount of a certain file block group in the second type of memory is equal to the sum of the maximum data amounts that all file blocks in the file block group can correspond to, it indicates that the increased data of the first file is not in this file block group.
[0065] When the data volume of the file block group in the second type of memory is less than the predicted data volume, it indicates that among all the file blocks included in the file block group, there is a file block whose data volume in the second type of memory is different from its data volume in the first type of memory. In this case, in an embodiment of the present invention, through a cache server, for any file block in the file block group: according to the serial number of the file block, determine the data volume of the file block in the second type of memory, and determine whether the data volume of the file block in the second type of memory is the same as the data volume of the file block in the first type of memory. Optionally, the addition of data to the first file in an embodiment of the present invention can be performed in ascending order of the serial numbers of the file blocks. First, add data to the file blocks in the multiple file blocks divided by the first file where the actual data volume corresponding to the file block has not reached the maximum data volume that the file block can correspond to. Therefore, if the data volume of a certain file block group in the second type of memory is different from the data volume of the file block group in the first type of memory, it is possible to first determine whether the data volume of the file block with the largest serial number among the file blocks included in the file block group in the second type of memory is the same as the data volume of the file block in the first type of memory. If they are different, update the file block stored in the second type of memory to the file block stored in the first type of memory.
[0066] In an optional embodiment of the present invention, the process of updating the file block stored in the second type of memory to the file block stored in the first type of memory can be: copying the data corresponding to the file block stored in the first type of memory to the file block stored in the second type of memory.
[0067] Specifically, in an embodiment of the present invention, the data corresponding to the file block stored in the first type of memory can overwrite the file block stored in the second type of memory, or the data added to the data of the file block stored in the second type of memory in the data corresponding to the file block stored in the first type of memory can be copied to the file block stored in the second type of memory.
[0068] A method for updating cached data provided by an embodiment of the present invention can obtain a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file; according to the file identifier, the starting position, and the offset of the first file in the first data request, determine the sequence numbers of at least one file block stored in a first type of memory and matching the data requested by the first data request; determine the data amounts of the file blocks in the first type of memory; according to the sequence numbers of the file blocks, determine the sequence number of the file block group where the data requested by the first data request is located; for any determined sequence number of file block group: according to the file identifier, determine the data amount of the file block group in a second type of memory, when the data amount of the file block group in the second type of memory is less than a preset data amount, determine the data amounts of the file blocks in the file block group in the second type of memory, for any file block in the file block group: according to the sequence number of the file block, determine whether the data amount of the file block in the first type of memory is the same as the data amount of the file block in the second type of memory, if different, update the file block stored in the second type of memory to the file block stored in the first type of memory. Because the present invention adopts the technical means that the data amounts of the file blocks with the same sequence numbers in the first type of memory and the second type of memory and the sequence numbers of the file block groups are also the same, it overcomes the technical problem that the cache memory cannot be updated, and further achieves the technical effect of keeping the data in the cache memory consistent with the data in the non-cache memory.
[0069] Corresponding to the above method embodiment, an embodiment of the present invention further provides a cached data update device, and its structure is as Figure 6 shown, including: a data request obtaining unit 100, a file block sequence number determining unit 200, a file block data amount determining unit 300, a file block group sequence number determining unit 400, and a file block updating unit 500.
[0070] The data request obtaining unit 100 is configured to obtain a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file.
[0071] Specifically, the identifier of the first file may be a characteristic identifier that distinguishes the first file from other files. For example, the identifier of the first file may be characteristic identifier A, and through characteristic identifier A, the storage position of the first file can be determined in a memory storing multiple files. The data requested by the first data request can be determined through the starting position and the offset of the first file.
[0072] The file block sequence number determination unit 200 is configured to determine the sequence numbers of at least one file block that is stored in the first type of memory and matches the data requested in the first data request according to the file identifier, start position, and offset of the first file in the first data request;
[0073] Specifically, in the embodiment of the present invention, the first file can be divided into multiple file blocks, and the maximum data volume corresponding to each file block can be the same. For example, if the data volume of the first file is 50 MB and the maximum data volume corresponding to each file block is 4 MB, then the first file can be divided into 13 file blocks. Among these 13 file blocks, 12 file blocks correspond to a data volume of 4 MB, and 1 file block corresponds to a data volume of 2 MB. The maximum data volume corresponding to each file block can be set according to actual needs, and the present invention does not make further limitations here. In the embodiment of the present invention, sequence numbers can be assigned to each file block in a preset first order.
[0074] The first type of memory can include multiple first type storage disks, and each first type storage disk can have one or more disk blocks. The storage spaces of the disk blocks in the first type of storage disk can be the same, where the storage space of the disk blocks in the first type of storage disk is the same as the maximum data volume that a file block can correspond to. Each disk block in the first type of memory can store a file block. The first type of memory can be a non-cache memory, and the non-cache memory can be a mechanical hard disk, a hybrid hard disk, etc., and the embodiment of the present invention does not make limitations here. The first type of memory can be communicatively connected to the index server, and the embodiment of the present invention can record the sequence numbers of at least one file block that matches the data requested in the first data request in the index server. During subsequent use, the embodiment of the present invention can determine the sequence numbers of at least one file block that matches the data requested in the first data request in the index server.
[0075] The file block data volume determination unit 300 is configured to determine the data volume of each file block in the first type of memory;
[0076] Specifically, the data volume of each file block corresponding to the first file can be recorded in the index server communicatively connected to the first type of memory. Although the maximum data volume corresponding to each file block can be the same, the actual data volume corresponding to each file block can be different. By recording the actual data volume of the file blocks in the first type of memory in the index server, the present invention can directly determine the data volume of each file block in the first type of memory in the index server.
[0077] The file block group sequence number determination unit 400 is configured to determine the sequence number of the file block group where the data requested in the first data request is located according to the sequence number of the file block;
[0078] Embodiments of the present invention can group multiple file blocks obtained by dividing a first file. Specifically, embodiments of the present invention can divide the multiple file blocks into one or more file block groups according to a preset quantity, and record the relationship between the file blocks included in the file block group and the file block group. At the same time, embodiments of the present invention can assign serial numbers to each file block group in a preset second order.
[0079] At the same time, embodiments of the present invention can record the serial numbers of each file block group in an index server. During subsequent use, embodiments of the present invention can determine the serial number of the file block group where the data requested by the first data request is located in the index server according to the serial number of the file block.
[0080] Optionally, the file block group serial number determination unit 400 can specifically be used for any file block in the at least one file block: according to the serial number of the file block, determine the serial number of the file block group to which the file block belongs, and determine the serial number of the file block group where part or all of the data requested by the first data request is located as the serial number of the file block group.
[0081] Optionally, the number of file blocks included in each file block group is the same, and the file block group serial number determination unit 400 is specifically used for each file block: subtract the starting serial number of the file block from the serial number of the file block, divide the result by the number of file blocks included in the file block group to obtain a quotient, round down the quotient, and determine the rounded-down result as the serial number of the file block group to which the file block belongs.
[0082] The file block update unit 500 is used for any file block group with a determined serial number: according to the file identifier, determine the data volume of the file block group in the second type of memory. When the data volume of the file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in the file block group in the second type of memory. For any file block in the file block group: according to the serial number of the file block, determine whether the data volume of the file block in the first type of memory is the same as the data volume of the file block in the second type of memory. If not, update the file block saved in the second type of memory to the file block saved in the first type of memory.
[0083] Specifically, through the file identifier, embodiments of the present invention can determine the storage location of the first file in the second type of memory, and then determine the data volume of the file block group in the second type of memory according to the file block group with the determined serial number. It should be noted that the data volume of the file block group with the same serial number in the first type of memory and the second type of memory may be the same or different.
[0084] The second type of memory may include a plurality of second type storage disks. Each second type storage disk may have one or more disk blocks, and the storage spaces of the disk blocks in the second type storage disk may be the same. Among them, the storage space of the disk blocks in the second type storage disk is the same as the maximum data volume that can be corresponding to a file block. Each disk block in the second type memory may store a file block.
[0085] It should be noted that the embodiments of the present invention may group the disk blocks in the second type memory. Specifically, the embodiments of the present invention may divide at least one disk block in each second type memory into a disk block group. Among them, the disk block groups to which the disk blocks in the same second type storage disk belong may be the same or different. The positions of the disk blocks included in the same disk block group in the second type storage disk are fixed.
[0086] The second type of memory may be a caching memory, and the caching memory may be a solid state drive, which is not limited in the present invention. The second type of memory may be communicatively connected to a cache server, and the cache server may be communicatively connected to an index server. The embodiments of the present invention may record the sequence numbers of at least one file block matching the data requested by the first data request, the sequence numbers of each file block group, the data volume of each file block in the second type memory, and the data volume of each file block group in the second type memory in the cache server. During subsequent use, the embodiments of the present invention may determine the data volume of the file block group in the second type memory according to the sequence number of the file block group in the cache server.
[0087] After determining the data volume of a certain file block group in the second type memory, the embodiments of the present invention may compare the data volume of the file block group in the second type memory with a preset data volume. The preset data volume may be a pre-judgment threshold for determining that the data volume of the file block group in the second type memory is different from the data volume of the file block group in the first type memory. Since the increase of the data of the first file in the embodiments of the present invention may first be performed on the file blocks in which the actually corresponding data volume of the file blocks divided from the first file does not reach the maximum data volume that can be corresponding to the file block, the preset data volume may be the sum of the maximum data volumes that can be corresponding to all the file blocks in the file block group. When the data volume of a certain file block group in the second type memory is equal to the sum of the maximum data volumes that can be corresponding to all the file blocks in the file block group, it indicates that the increased data of the first file is not in this file block group.
[0088] When the amount of data of the file block group in the second type of memory is less than the predicted amount of data, it indicates that among all the file blocks included in the file block group, there is a file block whose amount of data in the second type of memory is different from its amount of data in the first type of memory. In this case, in the embodiment of the present invention, through the cache server, for any file block in the file block group: according to the serial number of the file block, determine the amount of data of the file block in the second type of memory, and determine whether the amount of data of the file block in the second type of memory is the same as the amount of data of the file block in the first type of memory. Optionally, the increase of the data of the first file in the embodiment of the present invention can be performed in ascending order of the serial numbers of the file blocks. First, on the file blocks in the multiple file blocks divided by the first file where the actually corresponding amount of data of the file block does not reach the maximum amount of data that the file block can correspond to. Therefore, if the amount of data of a certain file block group in the second type of memory is different from the amount of data of the file block group in the first type of memory, it can first be determined whether the amount of data of the file block with the largest serial number among the file blocks included in the file block group in the second type of memory is the same as the amount of data of the file block in the first type of memory. If they are different, update the file block saved in the second type of memory to the file block saved in the first type of memory.
[0089] Optionally, the file block update unit 500 is specifically configured to copy the data corresponding to the file block saved in the first type of memory to the file block saved in the second type of memory.
[0090] Specifically, in the embodiment of the present invention, the data corresponding to the file block saved in the first type of memory can be used to overwrite the file block saved in the second type of memory, or the data increased relative to the data of the file block saved in the second type of memory in the data corresponding to the file block saved in the first type of memory can be copied to the file block saved in the second type of memory.
[0091] A cache data update device provided by an embodiment of the present invention can obtain a first data request, where the first data request carries a file identifier, a start position, and an offset of a first file; according to the file identifier, the start position, and the offset of the first file in the first data request, determine the sequence numbers of at least one file block saved in a first type of memory and matching the data requested by the first data request; determine the data amounts of the respective file blocks in the first type of memory; according to the sequence numbers of the file blocks, determine the sequence number of the file block group where the data requested by the first data request is located; for any determined sequence number of file block group: according to the file identifier, determine the data amount of this file block group in a second type of memory, when the data amount of this file block group in the second type of memory is less than a preset data amount, determine the data amounts of the respective file blocks in the second type of memory in this file block group, for any file block in this file block group: according to the sequence number of this file block, determine whether the data amount of this file block in the first type of memory is the same as the data amount of this file block in the second type of memory, if different, then update the file block saved in the second type of memory to the file block saved in the first type of memory. Because the present invention adopts the technical means that the data amounts of the file blocks with the same sequence numbers of the file blocks saved in the first type of memory and the second type of memory and the same sequence numbers of the file block groups are kept consistent, it overcomes the technical problem that the cache memory cannot be updated, and further achieves the technical effect of keeping the data in the cache memory consistent with the data in the non-cache memory.
[0092] A storage medium provided by an embodiment of the present invention is characterized in that computer-executable instructions are stored in the storage medium, and when the computer-executable instructions are loaded and executed by a processor, the cache data update method as described in any one of the above is implemented.
[0093] A computer device provided by an embodiment of the present invention is characterized in that it includes a processor, a memory, and a program stored on the memory and executable on the processor, and when the processor executes the program, it at least implements the following steps:
[0094] Obtain a first data request, where the first data request carries a file identifier, a start position, and an offset of a first file;
[0095] According to the file identifier, the start position, and the offset of the first file in the first data request, determine the sequence numbers of at least one file block saved in a first type of memory and matching the data requested by the first data request;
[0096] Determine the data amounts of the respective file blocks in the first type of memory;
[0097] Determine the serial number of the file block group where the data requested by the first data request is located according to the serial number of the file block;
[0098] For any file block group with a determined serial number: Determine the data volume of this file block group in the second type of memory according to the file identifier. When the data volume of this file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in this file block group in the second type of memory. For any file block in this file block group: Determine whether the data volume of this file block in the first type of memory is the same as the data volume of this file block in the second type of memory according to the serial number of this file block. If they are different, update the file block saved in the second type of memory to the file block saved in the first type of memory.
[0099] The cache data update device includes a processor and a memory. The above data request acquisition unit 100, file block serial number determination unit 200, file block data volume determination unit 300, file block group serial number determination unit 400, file block update unit 500, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.
[0100] The processor contains a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be set, and by adjusting the kernel parameters, the data volumes of the file blocks with the same serial numbers of the file blocks and the same serial numbers of the file block groups saved in the first type of memory and the second type of memory are kept consistent.
[0101] The memory may include non-permanent memory in a computer-readable medium, forms such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.
[0102] An embodiment of the present invention provides a storage medium, on which a program is stored, and when the program is executed by a processor, the cache data update method is implemented.
[0103] An embodiment of the present invention provides a processor, and the processor is used to run a program, wherein when the program runs, the cache data update method is executed.
[0104] An embodiment of the present invention provides a device, the device includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, the following steps are implemented:
[0105] Obtain a first data request, and the first data request carries a file identifier, a starting position, and an offset of a first file;
[0106] Determine the sequence numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request according to the file identifier, starting position, and offset of the first file in the first data request;
[0107] Determine the data volume of each file block in the first type of memory;
[0108] Determine the sequence number of the file block group where the data requested by the first data request is located according to the sequence number of the file block;
[0109] For any file block group with a determined sequence number: According to the file identifier, determine the data volume of this file block group in the second type of memory. When the data volume of this file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in this file block group in the second type of memory. For any file block in this file block group: According to the sequence number of this file block, determine whether the data volume of this file block in the first type of memory is the same as the data volume of this file block in the second type of memory. If they are different, update the file block stored in the second type of memory to the file block stored in the first type of memory.
[0110] Optionally, the determining the sequence number of the file block group where the data requested by the first data request is located according to the sequence number of the file block includes:
[0111] For any file block in the at least one file block: According to the sequence number of this file block, determine the sequence number of the file block group to which this file block belongs, and determine the sequence number of the file block group where part or all of the data requested by the first data request is located as the sequence number of this file block group.
[0112] Optionally, the updating the file block stored in the second type of memory to the file block stored in the first type of memory includes:
[0113] Copy the data corresponding to the file block stored in the first type of memory to the file block stored in the second type of memory.
[0114] Optionally, the preset data volume is the sum of the maximum data volumes corresponding to all file blocks in the file block group.
[0115] Optionally, the number of file blocks included in each file block group is the same. The determining the sequence number of the file block group where the data requested by the first data request is located according to the sequence number of the file block includes:
[0116] For each of the said file blocks: subtract the starting sequence number of the file block from the sequence number of the file block, divide the result by the number of file blocks included in the file block group to obtain a quotient, round down the quotient, and determine the rounded-down result as the sequence number of the file block group to which the file block belongs.
[0117] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0118] This application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program initialized with the following method steps:
[0119] Obtain a first data request, where the first data request carries the file identifier, starting position, and offset of a first file;
[0120] According to the file identifier, starting position, and offset of the first file in the first data request, determine the sequence numbers of at least one file block saved in the first type of memory and matching the data requested by the first data request;
[0121] Determine the data volume of each file block in the first type of memory;
[0122] According to the sequence number of the file block, determine the sequence number of the file block group where the data requested by the first data request is located;
[0123] For any file block group with a determined sequence number: according to the file identifier, determine the data volume of the file block group in the second type of memory. When the data volume of the file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in the file block group in the second type of memory. For any file block in the file block group: according to the sequence number of the file block, determine whether the data volume of the file block in the first type of memory is the same as the data volume of the file block in the second type of memory. If they are different, update the file block saved in the second type of memory to the file block saved in the first type of memory.
[0124] Optionally, the determining the sequence number of the file block group where the data requested by the first data request is located according to the sequence number of the file block includes:
[0125] For any file block in the at least one file block: according to the sequence number of the file block, determine the sequence number of the file block group to which the file block belongs, and determine the sequence number of the file block group where part or all of the data requested by the first data request is located as the sequence number of the file block group.
[0126] Optionally, the updating the file block saved in the second type of memory to the file block saved in the first type of memory includes:
[0127] Copy the data corresponding to the file block stored in the first type of memory to the file block stored in the second type of memory.
[0128] Optionally, the preset data volume is the sum of the maximum data volumes corresponding to all file blocks in the file block group.
[0129] Optionally, the number of file blocks included in each file block group is the same. Determining the serial number of the file block group where the data requested by the first data request is located according to the serial number of the file block includes:
[0130] For each of the file blocks: subtract the starting serial number of the file block from the serial number of the file block, divide the result by the number of file blocks included in the file block group to obtain a quotient, round down the quotient, and determine the rounded-down result as the serial number of the file block group to which the file block belongs.
[0131] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0132] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0133] These computer program instructions can also be stored in a computer-readable memory capable of guiding a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 steps of the functions specified in one block or multiple blocks.
[0135] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0136] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.
[0137] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0138] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, commodity or device including the element.
[0139] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.
[0140] The above are only the embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A method for updating cached data, characterized in that, Including: Obtaining a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file; Determining, according to the file identifier, the starting position, and the offset of the first file in the first data request, the sequence numbers of at least one file block saved in the first type of memory and matching the data requested by the first data request; Determining the data volume of each file block in the first type of memory; Determining, according to the sequence number of the file block, the sequence number of the file block group where the data requested by the first data request is located; For any determined sequence number of file block group: According to the file identifier, determining the data volume of this file block group in the second type of memory. When the data volume of this file block group in the second type of memory is less than a preset data volume, determining the data volume of each file block in this file block group in the second type of memory. For any file block in this file block group: According to the sequence number of this file block, determining whether the data volume of this file block in the first type of memory is the same as the data volume of this file block in the second type of memory. If they are different, updating the file block saved in the second type of memory to the file block saved in the first type of memory; where the preset data volume is the sum of the maximum data volumes that all file blocks in the file block group can correspond to; both the first type of memory and the second type of memory include multiple disk blocks, the storage space of the disk block is the same as the maximum data volume that a file block can correspond to, and the actual data volume corresponding to each file block is not greater than its maximum data volume.
2. The method according to claim 1, characterized in that, The determining, according to the sequence number of the file block, the sequence number of the file block group where the data requested by the first data request is located, includes: For any file block in the at least one file block: According to the sequence number of this file block, determining the sequence number of the file block group to which this file block belongs, and determining the sequence number of the file block group where part or all of the data requested by the first data request is located as the sequence number of this file block group.
3. The method according to claim 1, wherein The updating the file block saved in the second type of memory to the file block saved in the first type of memory includes: Copying the data corresponding to the file block saved in the first type of memory to the file block saved in the second type of memory.
4. The method according to claim 1, wherein The number of file blocks included in each file block group is the same. The determining, according to the sequence number of the file block, the sequence number of the file block group where the data requested by the first data request is located, includes: For each file block: Subtracting the starting sequence number of the file block from the sequence number of this file block, dividing the result by the number of file blocks included in the file block group to obtain a quotient, rounding down the quotient, and determining the rounded-down result as the sequence number of the file block group to which this file block belongs.
5. A cache data update device, characterized in that, Including: A data request obtaining unit, a file block sequence number determining unit, a file block data volume determining unit, a file block group sequence number determining unit, and a file block updating unit, The data request obtaining unit is used to obtain a first data request, where the first data request carries a file identifier, a starting position, and an offset of a first file; The file block serial number determination unit is configured to determine the serial numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request according to the file identifier, start position, and offset of the first file in the first data request; The file block data volume determination unit is configured to determine the data volume of each file block in the first type of memory; The file block group serial number determination unit is configured to determine the serial number of the file block group where the data requested by the first data request is located according to the serial number of the file block; The file block update unit is configured to, for any file block group with a determined serial number: determine the data volume of the file block group in the second type of memory according to the file identifier. When the data volume of the file block group in the second type of memory is less than the preset data volume, determine the data volume of each file block in the file block group in the second type of memory. For any file block in the file block group: determine whether the data volume of the file block in the first type of memory is the same as the data volume of the file block in the second type of memory according to the serial number of the file block. If they are different, update the file block stored in the second type of memory to the file block stored in the first type of memory; where the preset data volume is the sum of the maximum data volumes that all file blocks in the file block group can correspond to; both the first type of memory and the second type of memory include multiple disk blocks, the storage space of the disk block is the same as the maximum data volume that the file block can correspond to, and the actual data volume corresponding to each file block is not greater than its maximum data volume.
6. The device according to claim 5, characterized in that, The file block group serial number determination unit is specifically configured to, for any file block in the at least one file block: determine the serial number of the file block group to which the file block belongs according to the serial number of the file block, and determine the serial number of the file block group where part or all of the data requested by the first data request is located as the serial number of the file block group.
7. The device according to claim 5, characterized in that The file block update unit is specifically configured to copy the data corresponding to the file block stored in the first type of memory to the file block stored in the second type of memory.
8. A storage medium, characterized in that, The storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, the cache data update method described in any one of claims 1 to 4 above is implemented.
9. A computer device, characterized in that, It includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, it at least implements the following steps: Obtain a first data request, where the first data request carries the file identifier, start position, and offset of the first file; Determine the serial numbers of at least one file block stored in the first type of memory and matching the data requested by the first data request according to the file identifier, start position, and offset of the first file in the first data request; Determine the data volume of each file block in the first type of memory; Determine the serial number of the file block group where the data requested by the first data request is located according to the serial number of the file block; For any group of file blocks with a determined serial number: Determine the data volume of the group of file blocks in the second type of memory according to the file identifier. When the data volume of the group of file blocks in the second type of memory is less than the preset data volume, determine the data volume of each file block in the group of file blocks in the second type of memory. For any file block in the group of file blocks: Determine whether the data volume of the file block in the first type of memory is the same as the data volume of the file block in the second type of memory according to the serial number of the file block. If they are different, update the file block stored in the second type of memory to the file block stored in the first type of memory; where the preset data volume is the sum of the maximum data volumes that all file blocks in the group of file blocks can correspond to; both the first type of memory and the second type of memory include multiple disk blocks, the storage space of the disk block is the same as the maximum data volume that a file block can correspond to, and the actual data volume corresponding to each file block is not greater than its maximum data volume.
Citation Information
Patent Citations
Handling method and device for file transmission
CN106790653A
Data caching method and data caching device
CN109981774A