Data caching method and system
By dividing and integrating data blocks and caching and compression processing according to the cache pool space relationship, the problem of data cannot be effectively cached in the existing technology is solved, data caching efficiency is improved, and data storage is ensured efficient storage of data in memory.
Patent Information
- Application Number
- PCT/CN2023/125388
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-07-04
- Filing Date
- 2023-10-19
- Publication Date
- 2025-01-09
AI Technical Summary
The existing technology cannot effectively cache data, resulting in the inability to cache all the data into memory, resulting in increased resource consumption and reduced performance.
By receiving data cache requests, dividing data blocks, judging duplicate data blocks, integrating non-duplicate data blocks, and caching, compressing or replacing data based on the relationship between the remaining space capacity of the cache pool and the length of the data block, in order to optimize cache efficiency.
It improves data caching efficiency, solves the problem of not being able to reasonably and effectively cache data, and ensures that data can be stored in memory efficiently.
Smart Images

Figure CN2023125388_09012025_PF_FP_ABST
Abstract
Description
Data caching method and system Technical Field
[0001] The present invention relates to the technical field of data caching, and in particular to a data caching method and system. Background Art
[0002] Data caching refers to a high-speed cache with access speeds faster than typical random access buffers. Cache configuration is a key factor in the high performance of all modern computer systems. Currently, the use of caching technology to cache business data to reduce resource consumption caused by frequent database connections is becoming increasingly common. Because memory reads and writes data at speeds 100 times or more faster than hard disk reads and writes for database operations, memory caching can effectively improve operational efficiency. Most popular caching technologies in the industry implement memory caching.
[0003] In the prior art, to improve application performance, a data caching layer is added to the client or server. For example, a caching system can be added to the application or database server. The application pre-retrieves data from the database server and stores it in a non-persistent cache. When the client sends a request, the application retrieves the data from the data cache and returns it to the client. With the development of information network technology, server memory continues to grow, but disk caching capacity is growing at a faster rate. This inconsistent growth rate of server memory and disk caching capacity has led to a decrease in the ratio of memory capacity to disk capacity. Therefore, a more efficient method for data caching is needed.
[0004] Therefore, how to provide a method for reasonably and effectively caching data is a technical problem that needs to be solved. Summary of the Invention
[0005] The embodiments of the present invention provide a data caching method and system to solve the technical problem in the prior art that data cannot be reasonably and effectively cached and all data cannot be cached into a memory.
[0006] In order to achieve the above object, the present invention provides a data caching method, the method comprising:
[0007] receiving a data cache request, determining a data type of data to be cached based on the data cache request, querying a data cache pool from a data configuration service database according to the data type, and determining a corresponding data cache pool in a cache server according to query parameters of the data cache pool query;
[0008] Dividing the data to be cached into m data blocks, determining whether each data block is a duplicate data block, filtering out data blocks that are not duplicate data blocks based on the determination result, integrating the data blocks that are not duplicate data blocks, and obtaining data blocks to be cached, wherein the duplicate data blocks are data blocks whose contents have been cached, and m is an integer greater than 1;
[0009] caching the data blocks to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data blocks to be cached;
[0010] When performing data caching next time, the second remaining space capacity of the data cache pool is obtained, and the data cache pool is processed according to the second remaining space capacity of the data block to be cached.
[0011] In one embodiment, when dividing the data to be cached into m data blocks and determining whether each data block is a duplicate data block, the method includes:
[0012] Obtaining an n-1th data block, and determining whether the nth data block is a duplicate data block based on the n-1th data block, where n is an integer greater than 1 and less than or equal to n;
[0013] If the data of the n-1th data block includes the content of the nth data block, then the nth data block is determined to be a duplicate data block;
[0014] If the data of the n-1th data block does not include the content of the nth data block, it is determined that the nth data block is not a duplicate data block.
[0015] In one embodiment, before caching the data to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached, the method further includes:
[0016] Sending the data block to be cached to a data server, and determining whether the data block to be cached already exists in the data cache pool based on the data server,
[0017] If the data block to be cached already exists in the data cache pool, outputting a cached prompt message;
[0018] If the data block to be cached does not exist in the data cache pool, the data to be cached is cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached.
[0019] In one embodiment, when caching the data to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached, the method includes:
[0020] If the remaining space capacity of the data cache pool is greater than the length of the data block to be cached, the data block to be cached is cached in the data cache pool;
[0021] If the remaining space capacity of the data cache pool is equal to the length of the data block to be cached, compressing the data block to be cached to obtain compressed data, and caching the compressed data in the data cache pool;
[0022] If the remaining space capacity of the data cache pool is smaller than the length of the data block to be cached, the cached data block in the data cache pool is replaced.
[0023] In one embodiment, when caching the data block to be cached in the data cache pool, the method includes:
[0024] Determine the remaining space pointed to by the pointer in the data cache pool, wherein the remaining space is the address space in the data cache pool that can be used to cache data, including the address space from the address space pointed to by the pointer to the end of the data cache pool;
[0025] The data blocks to be cached are sequentially cached into the remaining space starting from the address space pointed to by the pointer.
[0026] In one embodiment, performing data compression on the data blocks to be cached and caching the compressed data blocks to be cached in the data cache pool includes:
[0027] Acquire the data block to be cached, and perform data compression on the data block to be cached based on a first compression method and a second compression method, respectively, to obtain first compressed data and second compressed data, wherein a compression ratio of the first compressed data is lower than a compression ratio of the second compressed data;
[0028] determining whether the compression ratio of the first compressed data is greater than or equal to a preset compression ratio,
[0029] If yes, determining the first compressed data as the compressed data corresponding to the data block to be cached;
[0030] If not, the second compressed data is determined as the compressed data corresponding to the data block to be cached.
[0031] In one embodiment, when replacing the cached data blocks in the data cache pool, the process includes:
[0032] Obtaining attention values of all cached data blocks in the data cache pool, and performing replacement processing on all cached data blocks in the data cache pool according to the relationship between the attention value of each cached data block and a preset attention value,
[0033] When the attention value is less than the preset attention value, the corresponding cached data block is replaced;
[0034] When the attention value is greater than or equal to the preset attention value, no replacement processing is performed on the corresponding cached data block.
[0035] In one embodiment, when all the attention values are smaller than the preset attention value or all the attention values are larger than the preset attention value, all the attention values are sorted and the cached data block with the smallest value is replaced.
[0036] In one embodiment, the data block to be cached includes: a key, a previous block address, a next block address, a data length, and data content.
[0037] In order to achieve the above object, the present invention provides a data caching system, the system comprising:
[0038] a determination module, configured to receive a data cache request, determine a data type of data to be cached based on the data cache request, perform a data cache pool query from a data configuration service database based on the data type, and determine a corresponding data cache pool in a cache server based on query parameters of the data cache pool query;
[0039] a determination module, configured to divide the data to be cached into m data blocks, determine whether each data block is a duplicate data block, filter out data blocks that are not duplicate data blocks based on the determination result, integrate the data blocks that are not duplicate data blocks, and obtain data blocks to be cached, wherein the duplicate data blocks are data blocks whose contents have been cached, and m is an integer greater than 1;
[0040] a cache module, configured to cache the data blocks to be cached according to a relationship between a remaining space capacity of the data cache pool and a length of the data blocks to be cached;
[0041] The replacement module is configured to obtain the second remaining space capacity of the data cache pool when performing data caching next time, and process the data cache pool according to the second remaining space capacity of the data block to be cached.
[0042] The present invention provides a data caching method and system, which has the following beneficial effects compared to the prior art:
[0043] The present invention discloses a data caching method and system, comprising: receiving a data caching request, determining a data type of data to be cached based on the data caching request, determining a corresponding data cache pool according to the data type, dividing the data to be cached into m data blocks, judging whether each data block is a duplicate data block, screening out data blocks that are not duplicate data blocks according to the judgment result and integrating them to obtain data blocks to be cached, caching the data blocks to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data blocks to be cached, obtaining a second remaining space capacity of the data cache pool when caching data next time, and processing the data cache pool according to the second remaining space capacity of the data blocks to be cached. The present invention solves the technical problem of being unable to reasonably and effectively cache data and unable to cache all data into memory, thereby improving data caching efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] FIG1 is a schematic diagram showing a flow chart of a data caching method according to an embodiment of the present invention;
[0045] FIG2 shows a schematic structural diagram of a data cache system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following embodiments of the present invention are described in further detail with reference to the accompanying drawings and examples. The following embodiments are used to illustrate the present invention but are not intended to limit the scope of the present invention.
[0047] In the description of this application, it should be understood that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on this application.
[0048] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the features. Throughout this application, unless otherwise specified, "plurality" means two or more.
[0049] In the description of this application, it should be noted that, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed, detachable, or integral connections; mechanical or electrical connections; direct or indirect connections through an intermediate medium; and internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in this application based on the specific circumstances.
[0050] The following is a description of preferred embodiments of the present invention with reference to the accompanying drawings.
[0051] As shown in FIG1 , an embodiment of the present invention discloses a data caching method, the method comprising:
[0052] S110: Receive a data cache request, determine the data type of the data to be cached based on the data cache request, query a data cache pool from a data configuration service database according to the data type, and determine a corresponding data cache pool in a cache server according to query parameters of the data cache pool query.
[0053] In this embodiment, when a data cache request is received, the data type of the data to be cached is determined. The data type can be power data, thermal power plant power generation data, thermal power unit operation data, etc., which are not given as examples here. According to the data type, a data cache pool query is performed from the data configuration business database, and the corresponding thermal power plant power generation data is determined in the cache server according to the query parameters of the data cache pool query. If the data type is thermal power plant power generation data, the thermal power plant power generation data is stored in the thermal power plant power generation data cache pool to avoid data confusion.
[0054] S120: Divide the data to be cached into m data blocks, determine whether each data block is a duplicate data block, filter out data blocks that are not duplicate data blocks based on the determination result, integrate the data blocks that are not duplicate data blocks, and obtain data blocks to be cached, wherein the duplicate data blocks are data blocks whose contents have been cached, and m is an integer greater than 1.
[0055] In some embodiments of the present application, when dividing the data to be cached into m data blocks and determining whether each data block is a duplicate data block, the process includes:
[0056] Obtaining an n-1th data block, and determining whether the nth data block is a duplicate data block based on the n-1th data block, where n is an integer greater than 1 and less than or equal to n;
[0057] If the data of the n-1th data block includes the content of the nth data block, then the nth data block is determined to be a duplicate data block;
[0058] If the data of the n-1th data block does not include the content of the nth data block, it is determined that the nth data block is not a duplicate data block.
[0059] In this embodiment, the n-1th data block is obtained, and whether the nth data block is a duplicate data block is determined based on the n-1th data block. Since the n-1th data block is the previous data block of the nth data block, when the data of the n-1th data block includes the content of the nth data block, the nth data block is determined to be a duplicate data block. Otherwise, the nth data block is determined to be a non-duplicate data block. After judging the m data blocks, the data blocks that are not duplicate data blocks are screened out, and the data blocks that are not duplicate data blocks are integrated to obtain the data blocks to be cached. The integration of the data blocks that are not duplicate data blocks includes restoring the data and then integrating them into a whole data block. The present invention can avoid caching duplicate data and improve data caching efficiency.
[0060] S130: Cache the data block to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached.
[0061] In some embodiments of the present application, before caching the data to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached, the method further includes:
[0062] Sending the data block to be cached to a data server, and determining whether the data block to be cached already exists in the data cache pool based on the data server,
[0063] If the data block to be cached already exists in the data cache pool, outputting a cached prompt message;
[0064] If the data block to be cached does not exist in the data cache pool, the data to be cached is cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached.
[0065] In this embodiment, the data block to be cached is sent to the data server. It should be noted that each time the data is successfully cached, the cached data is backed up to the data server. At the same time, after the data is replaced, the corresponding data in the data server is deleted. The data server determines whether the data block to be cached already exists in the data cache pool. If it already exists, a cached prompt message is output. Otherwise, the data to be cached is cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached. The present invention can avoid the phenomenon of caching the same data and avoid occupying a large amount of network resources.
[0066] In some embodiments of the present application, when caching the data to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached, the method includes:
[0067] If the remaining space capacity of the data cache pool is greater than the length of the data block to be cached, the data block to be cached is cached in the data cache pool;
[0068] If the remaining space capacity of the data cache pool is equal to the length of the data block to be cached, compressing the data block to be cached to obtain compressed data, and caching the compressed data in the data cache pool;
[0069] If the remaining space capacity of the data cache pool is smaller than the length of the data block to be cached, the cached data block in the data cache pool is replaced.
[0070] In this embodiment, whether to directly cache data can be determined based on the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached. If the remaining space capacity of the data cache pool is greater than the length of the data block to be cached, the data block to be cached is cached in the data cache pool. If the remaining space capacity of the data cache pool is equal to the length of the data block to be cached, the data block to be cached is compressed to obtain compressed data, and the compressed data is cached in the data cache pool. If the remaining space capacity of the data cache pool is less than the length of the data block to be cached, the data block to be cached is compressed to obtain compressed data, and the compressed data is cached in the data cache pool. The present invention can provide different data caching methods to ensure data caching efficiency.
[0071] In some embodiments of the present application, when caching the to-be-cached data block in the data cache pool, the process includes:
[0072] Determine the remaining space pointed to by the pointer in the data cache pool, wherein the remaining space is the address space in the data cache pool that can be used to cache data, including the address space from the address space pointed to by the pointer to the end of the data cache pool;
[0073] The data blocks to be cached are sequentially cached into the remaining space starting from the address space pointed to by the pointer.
[0074] In this embodiment, a pointer is also provided in the buffer pool to indicate the starting location of new data to be stored in the data buffer pool. When storing data in the data buffer pool, the data is preferentially stored in the address space that is still free in the buffer pool. The pointer can also be understood as pointing to the remaining space in the data buffer pool that can be used to store data. When the buffer pool is in an initialized state, the data buffer pool is empty in this embodiment of the present invention. At this time, the head of the buffer pool pointed to by the pointer, and the address space of the entire buffer pool, is free. When a data block needs to be stored in the data buffer pool, the pointer is first used to find the first remaining space in the data buffer pool and obtain the capacity of the first remaining space. This allows the determination of the number of data blocks that can be stored in the buffer pool. The data blocks to be cached are then sequentially cached in the remaining space, starting from the address space pointed to by the pointer. This invention can avoid the phenomenon of wasted storage space.
[0075] In some embodiments of the present application, performing data compression processing on the data blocks to be cached and caching the compressed data blocks to be cached in the data cache pool includes:
[0076] Acquire the data block to be cached, and perform data compression on the data block to be cached based on a first compression method and a second compression method, respectively, to obtain first compressed data and second compressed data, wherein a compression ratio of the first compressed data is lower than a compression ratio of the second compressed data;
[0077] determining whether the compression ratio of the first compressed data is greater than or equal to a preset compression ratio,
[0078] If yes, determining the first compressed data as the compressed data corresponding to the data block to be cached;
[0079] If not, the second compressed data is determined as the compressed data corresponding to the data block to be cached.
[0080] In this embodiment, when the first compression method and the second compression method are used for compression, as long as the compression ratio of the first compression method is lower than the compression ratio of the second compression method, the specific compression means are not specifically limited here. It is judged whether the compression ratio of the first compressed data is greater than or equal to the preset compression ratio. If so, the first compressed data is determined as the compressed data corresponding to the data block to be cached. If not, the second compressed data is determined as the compressed data corresponding to the data block to be cached. The present invention can make the data block to be cached meet the caching requirements by performing data compression processing on the data block to be cached.
[0081] In some embodiments of the present application, when replacing a cached data block in the data cache pool, the process includes:
[0082] Obtaining attention values of all cached data blocks in the data cache pool, and performing replacement processing on all cached data blocks in the data cache pool according to the relationship between the attention value of each cached data block and a preset attention value,
[0083] When the attention value is less than the preset attention value, the corresponding cached data block is replaced;
[0084] When the attention value is greater than or equal to the preset attention value, no replacement processing is performed on the corresponding cached data block.
[0085] In some embodiments of the present application, when all attention values are smaller than the preset attention value or all attention values are larger than the preset attention value, all attention values are sorted and the cached data block with the smallest value is replaced.
[0086] In this embodiment, the attention values of all cached data blocks in the data cache pool are obtained, wherein the attention value is defined according to the number of searches for the cached data block and is represented by a number, such as 215 times or 186 times. The preset attention value can be set according to actual conditions and is not specifically limited here, such as 110 times or 150 times. When the attention value is less than the preset attention value, the corresponding cached data block is replaced. When the attention value is greater than or equal to the preset attention value, the corresponding cached data block is not replaced. When the attention value is less than the preset attention value, it means that the corresponding cached data block has low attention and a small number of searches, so it can be replaced. When all attention values are less than the preset attention value, or all attention values are greater than the preset attention value, all attention values are sorted, and the cached data block with the smallest value is replaced. The present invention can accurately replace infrequently used content in the data cache pool, provide sufficient capacity space for the next data cache, and ensure normal data caching.
[0087] In some embodiments of the present application, the data block to be cached includes: a key, a previous block address, a next block address, a data length, and data content.
[0088] In this embodiment, key: through the key value and hash table, the storage location of the data block can be quickly found. The data blocks in the data cache pool are compactly stored, and the data blocks with the same key are connected through the "previous block address" and the "next block address" to form a bidirectional linked list. Previous block address: indicates the previous block of data with the same key value. It connects the data blocks to form a linked list. There is an empty address at the end of the linked list, indicating that the link ends here. Next block address: indicates the next block of data with the same key value. It also connects the data blocks to form another linked list. The direction of the chain is exactly opposite to that of the virtual curve linked list. In this way, the two linked lists form a bidirectional link. The head of the linked list can be quickly indexed in the hash table through the key. Data length: indicates the length of the data content. Data content: stores the data that needs to be cached.
[0089] S140: When performing data caching next time, obtain the second remaining space capacity of the data cache pool, and process the data cache pool according to the second remaining space capacity of the data block to be cached.
[0090] In this embodiment, when performing the next data caching, the second remaining space capacity of the data cache pool is obtained, that is, the remaining capacity of the data cache pool after completing the last data caching, and the data cache pool is processed according to the second remaining space capacity of the data block to be cached.
[0091] In order to further illustrate the technical idea of the present invention, the technical solution of the present invention is now described in combination with specific application scenarios.
[0092] Correspondingly, as shown in FIG2 , the present application further provides a data caching system, the system comprising:
[0093] a determination module, configured to receive a data cache request, determine a data type of data to be cached based on the data cache request, perform a data cache pool query from a data configuration service database based on the data type, and determine a corresponding data cache pool in a cache server based on query parameters of the data cache pool query;
[0094] a determination module, configured to divide the data to be cached into m data blocks, determine whether each data block is a duplicate data block, filter out data blocks that are not duplicate data blocks based on the determination result, integrate the data blocks that are not duplicate data blocks, and obtain data blocks to be cached, wherein the duplicate data blocks are data blocks whose contents have been cached, and m is an integer greater than 1;
[0095] a cache module, configured to cache the data blocks to be cached according to a relationship between a remaining space capacity of the data cache pool and a length of the data blocks to be cached;
[0096] The replacement module is configured to obtain the second remaining space capacity of the data cache pool when performing data caching next time, and process the data cache pool according to the second remaining space capacity of the data block to be cached.
[0097] In summary, the embodiment of the present invention receives a data cache request, determines the data type of the data to be cached based on the data cache request, determines the corresponding data cache pool according to the data type, divides the data to be cached into m data blocks, judges whether each data block is a duplicate data block, filters out data blocks that are not duplicate data blocks according to the judgment result and integrates them to obtain data blocks to be cached, caches the data blocks to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data blocks to be cached, and when the next data cache is performed, obtains the second remaining space capacity of the data cache pool, and processes the data cache pool according to the second remaining space capacity of the data blocks to be cached. The present invention solves the technical problem that data cannot be reasonably and effectively cached and all data cannot be cached in the memory, thereby improving data caching efficiency.
[0098] In the description of the above embodiments, specific features, structures, materials or characteristics may be combined in an appropriate manner in any one or more embodiments or examples.
[0099] Although the present invention has been described above with reference to exemplary embodiments, various modifications may be made and equivalent components may be substituted without departing from the scope of the present invention. In particular, the various features of the disclosed embodiments may be combined with one another in any manner, provided no structural conflicts exist. These combinations are not fully described in this specification solely for the sake of space and resource conservation. Therefore, the present invention is not limited to the specific embodiments disclosed herein, but encompasses all technical solutions within the scope of the claims.
[0100] Those skilled in the art will understand that the above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art will still be able to modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein with equivalents. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A data caching method, characterized in that: The method comprises: Receive a data cache request, determine a data type of data to be cached based on the data cache request, perform a data cache pool query from a data configuration service database according to the data type, and determine a corresponding data cache pool in a cache server according to a query parameter of the data cache pool query; Divide the data to be cached into m data blocks, determine whether each data block is a duplicate data block, filter out data blocks that are not duplicate data blocks according to the determination result, integrate the data blocks that are not duplicate data blocks, and obtain data blocks to be cached, wherein the duplicate data blocks are data blocks whose contents have been cached, and m is an integer greater than 1; Cache the data block to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached; When performing data caching next time, the second remaining space capacity of the data cache pool is obtained, and the data cache pool is processed according to the second remaining space capacity of the data block to be cached.
2. The data caching method according to claim 1, characterized in that: When the data to be cached is divided into m data blocks and each data block is judged whether it is a duplicate data block, the method includes: Obtaining an n-1th data block, and determining whether the nth data block is a duplicate data block according to the n-1th data block, where n is an integer greater than 1 and less than or equal to n; If the data of the n-1th data block includes the content of the nth data block, then the nth data block is determined to be a duplicate data block; If the data of the n-1th data block does not include the content of the nth data block, it is determined that the nth data block is not a duplicate data block.
3. The data caching method according to claim 1, characterized in that: Before caching the data to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached, the method further includes: Sending the data block to be cached to a data server, and determining whether the data block to be cached already exists in the data cache pool based on the data server, If the data block to be cached already exists in the data cache pool, outputting a cached prompt message; If the data block to be cached does not exist in the data cache pool, the data to be cached is cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached.
4. The data caching method according to claim 1, characterized in that: When the data to be cached is cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached, the method includes: If the remaining space capacity of the data cache pool is greater than the length of the data block to be cached, the data block to be cached is cached in the data cache pool; If the remaining space capacity of the data cache pool is equal to the length of the data block to be cached, the data block to be cached is subjected to data compression processing to obtain compressed data, and the compressed data is cached in the data cache pool; If the remaining space capacity of the data cache pool is smaller than the length of the data block to be cached, the cached data block in the data cache pool is replaced.
5. The data caching method according to claim 4, characterized in that: When caching the data block to be cached in the data cache pool, it includes: Determine the remaining space pointed to by the pointer in the data cache pool, wherein the remaining space is the address space in the data cache pool that can be used to cache data, including the address space from the address space pointed to by the pointer to the end of the data cache pool; The data blocks to be cached are cached in sequence into the remaining space starting from the address space pointed to by the pointer.
6. The data caching method according to claim 4, characterized in that: When the data blocks to be cached are subjected to data compression processing, and the data blocks to be cached after the data compression processing are cached in the data cache pool, the method includes: Acquire the data block to be cached, perform data compression on the data block to be cached based on a first compression method and a second compression method, respectively, and obtain first compressed data and second compressed data, respectively, wherein a compression ratio of the first compressed data is lower than a compression ratio of the second compressed data; determining whether the compression ratio of the first compressed data is greater than or equal to a preset compression ratio, If yes, determining the first compressed data as the compressed data corresponding to the data block to be cached; If not, the second compressed data is determined as the compressed data corresponding to the data block to be cached.
7. The data caching method according to claim 4, characterized in that: When replacing the cached data blocks in the data cache pool, it includes: Obtaining attention values of all cached data blocks in the data cache pool, and performing replacement processing on all cached data blocks in the data cache pool according to the relationship between the attention value of each cached data block and a preset attention value, When the attention value is less than the preset attention value, the corresponding cached data block is replaced; When the attention value is greater than or equal to the preset attention value, no replacement processing is performed on the corresponding cached data block.
8. The data caching method according to claim 7, characterized in that: When all the attention values are smaller than the preset attention value or all the attention values are larger than the preset attention value, all the attention values are sorted and the cached data block with the smallest value is replaced.
9. The data caching method according to claim 1, characterized in that: The data block to be cached includes: a key, a previous block address, a next block address, a data length, and data content.
10. A data cache system, characterized in that: The system comprises: A determination module, configured to receive a data cache request, determine a data type of data to be cached based on the data cache request, perform a data cache pool query from a data configuration service database according to the data type, and determine a corresponding data cache pool in a cache server according to a query parameter of the data cache pool query; a judgment module, used for dividing the data to be cached into m data blocks, judging whether each data block is a duplicate data block, filtering out data blocks that are not duplicate data blocks according to the judgment result, integrating the data blocks that are not duplicate data blocks, and obtaining data blocks to be cached, wherein the duplicate data blocks are data blocks whose contents have been cached, and m is an integer greater than 1; A cache module, used for caching the data block to be cached according to the relationship between the remaining space capacity of the data cache pool and the length of the data block to be cached; The replacement module is used to obtain the second remaining space capacity of the data cache pool when performing the next data cache, and process the data cache pool according to the second remaining space capacity of the data block to be cached.
Citation Information
Patent Citations
Data caching method
CN102436421A
Repeated data-based cache method achieved in cloud environment
CN106155934A
Cache management method, system and computer program product
CN116009760A
System for dynamically adaptive caching
EP2642397A1
Method for maximum data reduction combining compression with deduplication in storage arrays
US20200019329A1