Data cache processing method and device, equipment, storage medium and program product

By introducing thread-local storage space and pulse counting mechanism into the key-value storage database, cache management is optimized, solving the problem of frequent cache data eviction in existing technologies and improving data processing efficiency and cache reclamation reliability.

CN121597870APending Publication Date: 2026-03-03DAWNING INFORMATION IND (BEIJING) CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511598271.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-03
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

In existing technologies, there is a lack of effective management mechanisms for cached data generated when accessing the sorted string table (SST) in a key-value storage database. This leads to frequent eviction of hot cached data, resulting in frequent disk reads and reduced data processing efficiency.

Method used

Thread-local storage space is introduced, and the access list is updated by detecting thread access status to ensure that each thread independently maintains cached data. The main access list is used to manage the reclamation of cached data, and a pulse counting mechanism and historical access records are used to optimize cache management.

Benefits of technology

It improves the efficiency of multi-threaded access and the reliability of cache data management, ensures the rationality and reliability of cache reclamation, and enhances data processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597870A_ABST
    Figure CN121597870A_ABST
Patent Text Reader

Abstract

The invention relates to a data caching processing method and device, equipment, a storage medium and a program product. The method comprises the steps that under the condition that it is detected that a target thread accesses a target sorting character string table SST in a database, the storage condition of cache data of the target SST by other access chain tables corresponding to other threads is determined, the access chain table corresponding to each thread is located in a local storage space of the thread, and the access chain table corresponding to each thread is located in the local storage space of the thread; the data storage module is used for storing cache data of the SST accessed by the thread and updating a first access linked list according to the storage condition and the cache data of the target SST, the first access linked list at least comprises a target access linked list corresponding to the target thread, and the cache data of the target SST only exists in the updated target access linked list; and according to the cache data of each SST in the updated target access linked list, updating a main access linked list associated with the database, and carrying out recovery processing on the cache data of the SST based on the updated main access linked list. By adopting the method, the data processing efficiency can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data caching processing method, apparatus, device, storage medium, and program product. Background Technology

[0002] With the continuous development of the computer field, the amount of key-value index data that computer devices need to store has also increased. In order to efficiently store and query key-value index data, key-value databases (KVDBs) have emerged. They can store key-value data in a sorted string table (SST) format, and then persist the data in the SST to disk to achieve the purpose of actual storage.

[0003] However, due to the lack of an effective management mechanism for cached data generated by accessing SST in KVDB in the existing technology, problems such as frequent disk reads can occur when hot cached data is frequently evicted, thereby reducing the efficiency of data processing. Summary of the Invention

[0004] Therefore, it is necessary to provide a data caching processing method, apparatus, device, storage medium, and program product that can guarantee data processing efficiency in response to the above-mentioned technical problems.

[0005] Firstly, this application provides a data caching processing method, including:

[0006] If the target thread is detected to access the target sorted string table SST in the database, determine the storage status of the cached data of the target SST in other access lists corresponding to other threads; wherein, the access list corresponding to each thread is located in the thread's local storage space and is used to store the cached data of the SST accessed by the thread.

[0007] The first access list is updated based on the storage status and the cached data of the target SST; wherein the first access list includes at least the target access list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access list.

[0008] Based on the cached data of each SST in the updated target access list, the database-associated main access list is updated, and the cached data of the SST is recycled based on the updated main access list; the main access list is used to store the cached data of the SSTs to be recycled.

[0009] In this embodiment, on the one hand, an independent local storage space is introduced for each thread, and an access list is stored in the local storage space. When multiple threads access the SST, there is no need to control concurrency, which improves the efficiency of thread control. On the other hand, when an access event for the target SST is detected, the access list of each thread is updated to ensure that there is only one cached data of the target SST in each access list, which ensures the reliability of the main access list update and thus ensures the rationality of cache reclamation.

[0010] In one embodiment, the first access list further includes other access lists; updating the first access list based on storage conditions and cached data of the target SST includes:

[0011] If the target SST's cached data is stored in other access lists, migrate the target SST's cached data from the other access lists to the target access list.

[0012] In this embodiment of the application, when the cached data of the target SST is stored in other access lists, by moving the cached data of the target SST in other lists to the target access list, the reliability of the access hotness of the target SST cached data can be guaranteed, thereby ensuring the reliability of subsequent cached data reclamation.

[0013] In one embodiment, the first access list is updated based on the storage status and the cached data of the target SST, including:

[0014] If the cached data of the target SST is not stored in other access lists, query the cached data of the target SST in the target access list;

[0015] If the target SST is not found, add the cached data of the target SST to the target access list;

[0016] If the query is successful, update the write time of the cached data of the target SST in the target access list.

[0017] In this embodiment of the application, when the target SST cache data is not stored in other access lists, the flexibility and rationality of updating the target access list can be guaranteed by providing two update methods for the target access list.

[0018] In one embodiment, the main access list associated with the database is updated based on the cached data of each SST in the updated target access list, including:

[0019] Based on the write time of the cached data of each SST in the updated target access list, select the SST to be reclaimed from each SST in the target access list;

[0020] The cached data of SST to be reclaimed is migrated to the main access list associated with the database.

[0021] In this embodiment of the application, by updating the main access list according to the write time of the cached data of each SST in the updated target access list, the rationality of the main access list update can be guaranteed.

[0022] In one embodiment, the SST cache data reclamation process is performed based on the updated main access list, including:

[0023] Based on the write time of the cached data of each SST to be reclaimed in the updated main access list, select the SST to be reclaimed from each SST to be reclaimed, and use it as the current SST to be reclaimed.

[0024] Reclaim the cached data of the currently reclaimed SST.

[0025] In this embodiment, by selecting a certain number of SSTs' cache data from each SST to be reclaimed based on the write time of the cache data of each SST to be reclaimed in the main access chain, the accuracy of the cache reclamation amount is guaranteed, thus ensuring the rationality of cache reclamation.

[0026] In one embodiment, after determining the SST to be recycled from the SSTs to be recycled, the method further includes:

[0027] Once the access to the cached data for the currently recycled SST has ended, update the current pulse count;

[0028] Accordingly, the cached data of the currently reclaimed SST is reclaimed, including:

[0029] If an update to the current pulse count is detected, the cached data of the currently recycled SST is recycled.

[0030] In this embodiment, a pulse counting mechanism is introduced. By reclamating the cached data of the currently reclaimed SST when the current pulse count is updated, the reliability of SST cache data reclamation can be guaranteed.

[0031] In one embodiment, the method further includes:

[0032] In response to an SST access request, if it is determined that the SST corresponding to the SST access request is an SST in the currently recycled SST, the cached data of the SST corresponding to the SST access request is regenerated, and the cached data of the SST corresponding to the SST access request is added to the access list of the thread corresponding to the SST access request.

[0033] If it is determined that the SST corresponding to the SST access request is an SST in the SST to be reclaimed, the cached data of the SST corresponding to the SST access request is migrated to the access list of the thread corresponding to the SST access request.

[0034] In this embodiment of the application, by providing two processing methods for SST cache data in different states, the reliability of access task execution and the efficiency of linked list updates can be guaranteed.

[0035] In one embodiment, the method further includes:

[0036] If an increase in the cacheable amount associated with the database is detected, the SST to be cached is determined based on the increase in cache size, the historical access records of each SST in the database, and the access list of each thread at the current moment.

[0037] Add the cached data of the SST to be cached to the access list of any thread.

[0038] In this embodiment of the application, when the cacheable amount increases, the SST to be cached is determined based on the increase in cache size, the historical access records of each SST, and the access list of each thread, and the SST to be cached is pre-cached, which can effectively improve the efficiency of data access.

[0039] In one embodiment, the method further includes:

[0040] If a decrease in the cacheable amount associated with the database is detected, the SST reclamation amount is updated based on the amount of cache reduction.

[0041] In this embodiment, when the cacheable amount decreases, the SST reclamation amount is updated according to the amount of cache reduction to increase the subsequent cache reclamation amount, thereby saving the space memory where the database is located.

[0042] Secondly, this application also provides a data caching processing apparatus, comprising:

[0043] The storage detection module is used to determine the storage status of cached data of the target SST in other access lists corresponding to other threads when the target thread accesses the target sorted string table SST in the database. The access list corresponding to each thread is located in the thread's local storage space and is used to store the cached data of the SST accessed by the thread.

[0044] The linked list update module is used to update the first access linked list according to the storage status and the cached data of the target SST; wherein the first access linked list includes at least the target access linked list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access linked list.

[0045] The cache reclamation module is used to update the main access list associated with the database based on the cached data of each SST in the updated target access list, and to reclaim the cached data of the SST based on the updated main access list; wherein, the main access list is used to store the cached data of the SST to be reclaimed.

[0046] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0047] If the target thread is detected to access the target sorted string table SST in the database, determine the storage status of the cached data of the target SST in other access lists corresponding to other threads; wherein, the access list corresponding to each thread is located in the thread's local storage space and is used to store the cached data of the SST accessed by the thread.

[0048] The first access list is updated based on the storage status and the cached data of the target SST; wherein the first access list includes at least the target access list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access list.

[0049] Based on the cached data of each SST in the updated target access list, the database-associated main access list is updated, and the cached data of the SST is recycled based on the updated main access list; the main access list is used to store the cached data of the SSTs to be recycled.

[0050] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0051] If the target thread is detected to access the target sorted string table SST in the database, determine the storage status of the cached data of the target SST in other access lists corresponding to other threads; wherein, the access list corresponding to each thread is located in the thread's local storage space and is used to store the cached data of the SST accessed by the thread.

[0052] The first access list is updated based on the storage status and the cached data of the target SST; wherein the first access list includes at least the target access list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access list.

[0053] Based on the cached data of each SST in the updated target access list, the database-associated main access list is updated, and the cached data of the SST is recycled based on the updated main access list; the main access list is used to store the cached data of the SSTs to be recycled.

[0054] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0055] If the target thread is detected to access the target sorted string table SST in the database, determine the storage status of the cached data of the target SST in other access lists corresponding to other threads; wherein, the access list corresponding to each thread is located in the thread's local storage space and is used to store the cached data of the SST accessed by the thread.

[0056] The first access list is updated based on the storage status and the cached data of the target SST; wherein the first access list includes at least the target access list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access list.

[0057] Based on the cached data of each SST in the updated target access list, the database-associated main access list is updated, and the cached data of the SST is recycled based on the updated main access list; the main access list is used to store the cached data of the SSTs to be recycled.

[0058] The aforementioned data caching processing method, apparatus, device, storage medium, and program product, upon detecting that a target thread accesses a target SST in the database, determines the storage status of cached data for the target SST in other access lists corresponding to other threads, and updates the first access list based on the storage status and the cached data of the target SST. Then, based on the updated cached data of each SST in the target access list, the main access list associated with the database is updated, and the cached data of the SST is reclaimed based on the updated main access list. This method, on the one hand, introduces independent local storage space for each thread, storing the access list in the local storage space. This eliminates the need to control concurrency during multi-threaded access, improving the efficiency of thread management. On the other hand, upon detecting an access event for the target SST, updating the access lists of each thread ensures that only one cached data of the target SST exists in each access list, guaranteeing the reliability of the main access list update and thus ensuring the rationality of cache reclamation. Attached Figure Description

[0059] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0060] Figure 1 This is a schematic diagram of the database structure in one embodiment;

[0061] Figure 2 This is a schematic diagram of the layout of a local storage component in one embodiment;

[0062] Figure 3 This is a flowchart illustrating a data caching process in one embodiment;

[0063] Figure 4 This is a schematic diagram illustrating the construction of the main access linked list in one embodiment;

[0064] Figure 5 This is a schematic diagram of SST migration in one embodiment;

[0065] Figure 6 This is a schematic diagram of SST migration in another embodiment;

[0066] Figure 7 This is a schematic diagram of SST migration in yet another embodiment;

[0067] Figure 8 This is a schematic diagram of pulse emptying in one embodiment;

[0068] Figure 9 This is a flowchart illustrating the data caching process in another embodiment;

[0069] Figure 10 This is a structural block diagram of a data caching processing device in one embodiment;

[0070] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0071] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0072] With the continuous development of the computer field, the amount of key-value index data that computer devices need to store has also increased. In order to efficiently store and query key-value index data, KVDB emerged, which can store key-value data in SST format, and then persist the data in SST to disk to achieve the purpose of true storage.

[0073] However, due to the lack of an effective management mechanism for cached data generated by accessing SST in KVDB in the existing technology, problems such as frequent disk reads can occur when hot cached data is frequently evicted, thereby reducing the efficiency of data processing.

[0074] In this application embodiment, a mechanism for constructing thread-local storage space is provided, referring to... Figure 1 The database structure diagram shown depicts a top-level memory layer. This layer operates entirely in memory, offering high speed and efficiency, but memory capacity is limited, requiring data to be promptly cached and stored. Below this are the L0 and B-tree layers. Data in these layers is persisted to disk, but a copy is also cached in memory to ensure fast query performance. The storage units in the L0 and B-tree layers are SSTs, which are also the basic objects used for caching.

[0075] This application introduces a thread-local storage component, tlsMgr, associated with the database. Internally, tlsMgr supports private space items (tlsMgrItem) for each thread, with the number and size of these items dynamically configurable. The tlsMgr structure contains a name, size, number of tlsMgrItems, an array of tlsMgrItem addresses, and a corresponding bitMap table to record the usage of each tlsMgrItem. Furthermore, to facilitate the initialization, destruction, and viewing of the contents of each tlsMgrItem by threads, tlsMgr provides various processing callbacks. These include calling the corresponding initialization callback when a tlsMgrItem is created, the corresponding destruction callback when a tlsMgrItem is destroyed, and the corresponding viewing callback when tlsMgrItems are iterated over.

[0076] It is worth noting that tlsMgr only uses read-write locks for concurrency control when creating and destroying items in the private space tlsMgrItem. Internal access and modification scenarios do not require concurrency control because each thread has its own space, so there is no lock. This achieves lock-free operation at application time and enables each thread to control its own cached information in a lock-free, concurrent, and efficient manner.

[0077] For further information, please refer to... Figure 2The diagram illustrates the layout of local storage components within a process. A process contains several threads (e.g., thread 1, thread 2, thread 3, ...), and the database is associated with several thread-local storage components. Each thread-local storage component corresponds to a KVBD instance (e.g., a B-tree) in the database.

[0078] Each thread operates on a single KVDB instance and uses its own private space item. When a task on a thread performs KVDB insertion, traversal, or query operations, it triggers cache information modification and requires cache information updates. The private space item belonging to that thread can be retrieved from the thread-local storage component of the current KVDB instance, and the relevant information in the corresponding private space item can be updated. This achieves the effect of non-interference and concurrent updates between threads, improving cache management efficiency.

[0079] Based on this, in an exemplary embodiment, a data caching processing method is provided, which will be described using an example of the method being applied to a server. Figure 3 As shown, the specific steps include:

[0080] S301, if it is detected that the target thread accesses the target SST in the database, determine the storage status of the cached data of the target SST in other access lists corresponding to other threads.

[0081] In this context, the target thread is the thread that initiates the access request for the target SST. The target SST is the SST that the target thread wants to access. Each thread's access list is located in its local storage space and is used to store cached data of the SST accessed by that thread. Other threads are any threads that can access the database other than the target thread. Furthermore, other access lists are the access lists stored by these other accessing threads. The storage status refers to whether the cached data of the target SST is stored in these other access lists.

[0082] It is understandable that, since each thread maintains its own access list independently, there may be a SST cache data that is frequently accessed in access list A but less frequently accessed in access list B. In this case, when reclaiming SST cache data with low access frequency in each access list, this SST cache data may be identified as the SST cache data that needs to be reclaimed, thereby affecting the thread in access list A from accessing that SST cache data.

[0083] Therefore, when access to the target SST in the database is detected by a target thread, it is necessary to query the storage status of the target SST's cached data in the other access lists corresponding to each other thread, based on the target SST's identification information. In other words, it is necessary to determine whether cached data of the target SST exists in the other access lists.

[0084] S302, update the first access list based on the storage status and the cached data of the target SST.

[0085] The so-called first access list is the access list to be updated based on the target SST access event. Furthermore, the first access list includes at least the target access list corresponding to the target thread, and the cached data of the target SST only exists in the updated target access list.

[0086] In one alternative implementation, the first access list to be updated can be determined first based on the storage situation. For example, if other access lists store cached data of the target SST, the first access list may include both the target access list and other access lists where the cached data of the target SST is located; if other access lists do not store cached data of the target SST, the first access list may include only the target access list.

[0087] Understandably, to more intuitively analyze the access frequency of each SST cache data in the access list, the SST cache data in the access list can be sorted based on the access frequency. For example, the SST cache data with higher access frequency can be arranged at the head of the list.

[0088] Therefore, the first access list can be updated by updating the list position of the cached data of the target SST in the first access list. For example, if the first access list only includes the target access list, the cached data of the target SST can be directly migrated to the head of the target access list.

[0089] It is worth noting that, in order to avoid the target SST's cached data being mistakenly reclaimed, if the first access list also includes other access lists, it is necessary to clear the target SST's cached data in the other access lists.

[0090] S303: Based on the cached data of each SST in the updated target access list, update the main access list associated with the database, and perform SST cached data reclamation processing based on the updated main access list.

[0091] The main access list is used to store cached data of SSTs to be reclaimed. For example, refer to... Figure 4The diagram shows the construction of the main access list. SST caches with lower access frequency in each access list can be migrated to the main access list.

[0092] Optionally, to ensure the reliability of the main access list, after the target access list is updated, the cached data of SSTs with lower access popularity can be determined based on the data popularity of the cached data of each SST in the updated target access list, and the cached data of the SSTs to be reclaimed can be migrated to the main access list.

[0093] For example, the cached data of the SST located at the tail of the target access list after the update can be directly migrated to the main access list as the cached data of the SST to be reclaimed; or, the write time of the cached data of the SST located at the tail of the target access list can be compared with the cached data reclamation time range, and if the write time is within the cached data reclamation time range, the cached data of the SST can be migrated to the main access list.

[0094] After updating the main access list, upon detecting a cache reclamation event, the cached data of all SSTs awaiting reclamation in the main access list can be reclaimed. Alternatively, based on the access frequency of the cached data of each SST, only the cached data of SSTs with lower access frequency can be reclaimed. The cache reclamation event can be generated automatically based on a preset reclamation period or when a cache reclamation request is detected; this embodiment does not impose any restrictions on this.

[0095] In the aforementioned data caching method, when an access to a target SST in the database by a target thread is detected, the storage status of cached data for the target SST in other access lists corresponding to other threads is determined. Based on the storage status and the cached data of the target SST, the first access list is updated. Then, based on the updated cached data of each SST in the target access list, the main access list associated with the database is updated, and the cached data of the SST is reclaimed based on the updated main access list. This method, on the one hand, introduces independent local storage space for each thread, storing the access list in this local storage space. This eliminates the need for concurrency control during multi-threaded access, improving the efficiency of thread management. On the other hand, when an access event to the target SST is detected, updating the access lists of each thread ensures that only one cached data of the target SST exists in each access list, guaranteeing the reliability of the main access list update and thus ensuring the rationality of cache reclamation.

[0096] Based on the above embodiments, in this application embodiment, when the first access list also includes other access lists, an optional method for updating the list is provided. Specifically, when the storage situation is that the cached data of the target SST is stored in other access lists, the cached data of the target SST in the other access lists is migrated to the target access list.

[0097] Understandably, if the target SST's cached data is stored in other access lists, to prevent the target SST's cached data from being mistakenly reclaimed, one can refer to... Figure 5 The SST migration diagram shown directly moves the cached data of the target SST in other linked lists to the target access linked list.

[0098] In this embodiment of the application, when the cached data of the target SST is stored in other access lists, by moving the cached data of the target SST in other lists to the target access list, the reliability of the access hotness of the target SST cached data can be guaranteed, thereby ensuring the reliability of subsequent cached data reclamation.

[0099] Furthermore, when the first access list only includes the target access list, an alternative list update method is provided. Specifically, if the target SST's cached data is not stored in other access lists, the target SST's cached data is queried in the target access list; if not found, the target SST's cached data is added to the target access list; if found, the write time of the target SST's cached data in the target access list is updated.

[0100] The write time refers to the time when cached data is written, which reflects the access frequency of cached data. That is, the closer the write time is to the current time, the higher the access frequency of cached data; the further the write time is from the current time, the lower the access frequency of cached data.

[0101] Optionally, to ensure the reliability of the target SST's cached data in the target access list, the target SST's identification information can be used to query the target SST's cached data in the target access list. If it is determined that the target SST's cached data does not exist in the target access list, the target SST's cached data can be directly added to the target access list, and the current time can be used as the write time of the target SST's cached data. For example, the target SST's cached data can be directly added to the head of the target access list.

[0102] If it is determined that cached data for the target SST exists in the target access list, then the current time can be directly used as the write time of the cached data for the target SST to update the write time of the cached data for the target SST. For example, you can refer to... Figure 6 The SST migration diagram shown moves the cached data of the target SST in the target access list to the head of the list, and uses the current time as the new write time of the target SST cached data.

[0103] In this embodiment of the application, when the target SST cache data is not stored in other access lists, the flexibility and rationality of updating the target access list can be guaranteed by providing two update methods for the target access list.

[0104] Based on the above embodiments, this application provides an optional method for updating the main access list. Specifically, according to the write time of the cached data of each SST in the updated target access list, an SST to be reclaimed is selected from each SST in the target access list; the cached data of the SST to be reclaimed is migrated to the main access list associated with the database.

[0105] The SST to be reclaimed refers to the SST corresponding to the cached data that needs to be moved into the main access list.

[0106] Optionally, the write time range of the cache to be reclaimed in the current round can be determined based on the current time and the preset cache reclamation period; then, it is determined whether the write time of the cache data of each SST in the updated target access list is within the write time range, and the SST cache data within the write time range is taken as the SST to be reclaimed.

[0107] Furthermore, cached data of SSTs to be reclaimed can be directly migrated to the main access list associated with the database. For example, based on the position of each SST cache data in the target access list, the write time of each SST cache data is queried sequentially from the head of the list to see if it falls within the write time range. After detecting the first SST cache data within the write time range, this SST cache data and other SST cache data following it can be migrated to the main access list associated with the database as SSTs to be reclaimed.

[0108] It is worth noting that, in order to ensure the rationality of the position of each SST cache data in the main access list, the SST cache data can be arranged in order of recent to distant write time based on the write time of each existing SST cache data in the main access list and the write time of the SST cache data to be reclaimed in this case, so as to obtain the updated main access list.

[0109] In this embodiment of the application, by updating the main access list according to the write time of the cached data of each SST in the updated target access list, the rationality of the main access list update can be guaranteed.

[0110] Based on the above embodiments, this application provides an optional method for cache reclamation, specifically, according to the write time of the cache data of each SST to be reclaimed in the updated main access list, select an SST to be reclaimed from each SST to be reclaimed as the current SST to be reclaimed; and perform cache reclamation processing on the cache data of the currently reclaimed SST.

[0111] The SST reclamation amount refers to the amount of SST cached data to be reclaimed in this round. Furthermore, the SST reclamation amount can be determined based on the amount of cache to be reclaimed; for example, the ratio between the total cache size and the amount of data in each SST cached data set can be used as the SST reclamation amount. The currently reclaimed SST refers to the SST corresponding to the cached data to be reclaimed in the current round.

[0112] Understandably, when there is a lot of SST cached data in the main access list, in order to improve the efficiency of cache reclamation, each round can only reclaim SST cached data with low access frequency in the main access list.

[0113] Optionally, the cached data of each SST to be reclaimed can be sorted according to the write time of each cached data of each SST to be reclaimed in the updated main access list, in order of the write time from the nearest to the farthest, and the SST to be reclaimed at the end of the list can be used as the current SST to be reclaimed.

[0114] For example, refer to Figure 7 The SST migration diagram shown illustrates that when the cached data of each SST in the main access list is sorted from most recent to furthest based on the write time, and the SST reclamation quantity is 3, the cached data of SST4-6 located at the end of the main access list can be migrated to the current reclamation list, referring to the current reclamation list construction diagram shown in Figure 7.

[0115] Furthermore, if no access events are detected for the currently reclaimed SST, the cached data of the currently reclaimed SST can be reclaimed.

[0116] In this embodiment, by selecting a certain number of SSTs' cache data from each SST to be reclaimed based on the write time of the cache data of each SST to be reclaimed in the main access chain, the accuracy of the cache reclamation amount is guaranteed, thus ensuring the rationality of cache reclamation.

[0117] Understandably, after identifying the SST to be reclaimed, the cached data of that SST cannot be directly reclaimed due to the possibility of other tasks accessing it. Related technologies can use reference counting to clear tasks and then release the corresponding SST cached data. However, using reference counting requires considering concurrency; that is, a single count modified simultaneously by multiple threads will result in inaccuracies.

[0118] In this embodiment, a pulse exhaust mechanism is introduced. Multiple threads within a process run their own access tasks, which vary in duration and interval, and there are instances where multiple threads simultaneously access the same SST. In this case, a reference can be made... Figure 8 The pulse drain diagram shown treats each thread as a pipeline, with each pipeline executing each access task sequentially. When the pulse drain mechanism is first started, pulse line 1 can be set at any time. The pulse lines in the pulse drain mechanism are driven by the "access task completion" event. That is, for any pulse line, the next pulse line will only be pushed forward when the preset monitoring thread detects that all access tasks spanned by that pulse line have been completed.

[0119] For example, continue to refer to Figure 8 The diagram illustrating pulse emptying shows that when SST1 is the currently recycled SST, there is an access task 1 for thread 1 targeting SST1, represented by pulse line 2. Pulse line 2 spans access tasks 1 and 2. Therefore, pulse count can only be updated and pulse line 3 generated after the monitoring thread confirms that access tasks 1 and 2 have finished their accesses. Pulse line 3 spans access tasks 3 and 4. Pulse count can only be updated and pulse line 4 generated after the monitoring thread confirms that access tasks 3 and 4 have finished their accesses.

[0120] Based on this, and building upon the above embodiments, in this application embodiment, after determining the SST to be recycled from each SST to be recycled, another optional method for cache recycling is provided. Specifically, after detecting that the access to the cache data of the currently recycled SST has ended, the current pulse count is updated; and if the current pulse count is updated, the cache data of the currently recycled SST is recycled.

[0121] The so-called current pulse count is the pulse count used to determine the current SST recovery.

[0122] In one alternative embodiment, after determining the current SST to be recycled, the current pulse count can be recorded, and the monitoring thread can monitor whether the access task for the current SST to be recycled has ended; then, after detecting that the access task for the current SST to be recycled has ended, the monitoring thread can be controlled to update the current pulse count.

[0123] Furthermore, given the current pulse count update, it is proven that there are no access tasks for the currently reclaimed SST. In this case, the cached data of the currently reclaimed SST can be reclaimed.

[0124] In this embodiment, a pulse counting mechanism is introduced. By reclamating the cached data of the currently reclaimed SST when the current pulse count is updated, the reliability of SST cache data reclamation can be guaranteed.

[0125] Based on the above embodiments, this application provides another optional method for linked list updates. Specifically, in response to an SST access request, if it is determined that the SST corresponding to the SST access request is an SST currently being recycled, the cached data of the SST corresponding to the SST access request is regenerated, and the cached data of the SST corresponding to the SST access request is added to the access linked list of the thread corresponding to the SST access request; if it is determined that the SST corresponding to the SST access request is an SST to be recycled, the cached data of the SST corresponding to the SST access request is migrated to the access linked list of the thread corresponding to the SST access request. Here, an SST access request is a request to access an SST in the database.

[0126] When an SST access request is detected, the status of the cached data of the SST corresponding to the SST access request can be determined based on the identifier information of the SST to be accessed.

[0127] In one alternative implementation, if it is determined that the SST corresponding to the SST access request is an SST in the currently reclaimed SST, it proves that the cached data of the SST corresponding to the SST access request is about to be reclaimed. At this time, in order to ensure the reliability of access, the cached data of the SST corresponding to the SST access request can be regenerated. After that, the newly generated cached data can be stored in the access list of the thread corresponding to the SST access request.

[0128] In another alternative implementation, if it is determined that the SST corresponding to the SST access request is an SST in the SST to be reclaimed, it proves that the cached data of the SST corresponding to the SST access request is not in the current reclamation round. Therefore, the cached data of the SST corresponding to the SST access request can be directly migrated to the access list of the thread corresponding to the SST access request.

[0129] In this embodiment of the application, by providing two processing methods for SST cache data in different states, the reliability of access task execution and the efficiency of linked list updates can be guaranteed.

[0130] Based on the above embodiments, in this application embodiment, when the cacheable amount of the database changes, an optional data caching method is provided. Specifically, when an increase in the cacheable amount associated with the database is detected, the SST to be cached is determined according to the increase in cache, the historical access records of each SST in the database, and the access list of each thread at the current moment; the cached data of the SST to be cached is added to the access list of any thread.

[0131] The increase in cache size refers to the increase in the amount of data that the database can cache. Historical access records refer to records of accesses to each SST within a historical time period. SSTs to be cached are those that need to be pre-cached.

[0132] Optionally, the available memory space associated with the database can be monitored. If an increase in available memory space is detected, it can be determined that the cacheable amount of the database association has increased. In this case, to improve the efficiency of subsequent SST accesses, SSTs with high access frequency can be pre-cached.

[0133] Specifically, based on the historical access records of each SST in the database, each SST can be sorted according to its access popularity to obtain an SST popularity sorting table. Then, the cached SSTs in the access chain of each thread at the current moment are removed from the SST popularity sorting table to obtain an uncached SST popularity sorting table.

[0134] Furthermore, based on the increase in cache size and the amount of SST data, the number of SSTs to be cached can be determined, and the top-ranked SSTs in the uncached SST popularity ranking list can be used as the SSTs to be cached. After caching the SSTs to be cached, the cached data of the SSTs to be cached can be added to the access list of any thread to complete the pre-caching process.

[0135] In this embodiment of the application, when the cacheable amount increases, the SST to be cached is determined based on the increase in cache size, the historical access records of each SST, and the access list of each thread, and the SST to be cached is pre-cached, which can effectively improve the efficiency of data access.

[0136] Based on the above embodiments, this application provides another optional data caching method when the cacheable amount of the database changes. Specifically, when a decrease in the cacheable amount associated with the database is detected, the SST reclamation amount is updated according to the amount of cache reduction. Here, the cache reduction amount refers to the decrease in the amount of cacheable data in the database.

[0137] Optionally, the available memory space associated with the database can be monitored. If a decrease in available memory space is detected, it can be determined that the cacheable amount associated with the database has decreased. In this case, to save memory space, the cache reclamation amount can be increased. Specifically, the required increase in SST reduction can be determined based on the cache reduction amount and the SST data volume; then, the sum of the SST reduction amount and the current SST reclamation amount is used as the new SST reclamation amount. Furthermore, in the next reclamation round, cache reclamation can be performed based on the new SST reclamation amount.

[0138] In this embodiment, when the cacheable amount decreases, the SST reclamation amount is updated according to the amount of cache reduction to increase the subsequent cache reclamation amount, thereby saving the space memory where the database is located.

[0139] Figure 9 This is a flowchart illustrating a data caching method in another embodiment. Based on the above embodiments, this embodiment provides an optional example of a data caching method. (Combined with...) Figure 9 The specific implementation process is as follows:

[0140] S901, if it is detected that the target thread accesses the target SST in the database, obtain the storage status of the cached data of the target SST in other access lists corresponding to other threads.

[0141] Each thread's access list is located in the thread's local storage space and is used to store cached data of the SST accessed by the thread.

[0142] S902, based on the storage situation, determine whether there is cached data for the target SST in other access lists. If yes, execute S903; otherwise, execute S904.

[0143] S903: Migrate the cached data of the target SST from other access lists to the target access list. Then execute S905.

[0144] S904: If cached data of target SST exists in the target access chain, update the write time of cached data of target SST in the target access chain; if cached data of target SST does not exist in the target access chain, add cached data of target SST to the target access chain.

[0145] S905: Based on the write time of the cached data of each SST in the updated target access list, select the SST to be reclaimed from each SST in the target access list, and migrate the cached data of the SST to be reclaimed to the main access list associated with the database.

[0146] S906: Based on the write time of the cached data of each SST to be reclaimed in the updated main access list, select the SST to be reclaimed from each SST to be reclaimed as the current SST to be reclaimed.

[0147] S907, after detecting that the access to the cached data for the currently recycled SST has ended, update the current pulse count.

[0148] S908, upon detecting an update to the current pulse count, performs a recycling process on the cached data of the currently recycled SST.

[0149] The specific processes of S901-S908 described above can be found in the description of the above method embodiments. Their implementation principles and technical effects are similar, and will not be repeated here.

[0150] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0151] Based on the same inventive concept, this application also provides a data caching processing apparatus for implementing the data caching processing method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more data caching processing apparatus embodiments provided below can be found in the limitations of the data caching processing method described above, and will not be repeated here.

[0152] In one exemplary embodiment, such as Figure 10 As shown, a data caching processing device 1 is provided, including: a storage detection module 10, a linked list update module 20, and a cache reclamation module 30, wherein:

[0153] The storage detection module 10 is used to determine the storage status of cached data of the target SST in other access lists corresponding to other threads when the target thread accesses the target sorted string table SST in the database; wherein, the access list corresponding to each thread is located in the thread's local storage space and is used to store the cached data of the SST accessed by the thread.

[0154] The linked list update module 20 is used to update the first access linked list according to the storage status and the cached data of the target SST; wherein the first access linked list includes at least the target access linked list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access linked list.

[0155] The cache reclamation module 30 is used to update the main access list associated with the database based on the cached data of each SST in the updated target access list, and to reclaim the cached data of the SST based on the updated main access list; wherein, the main access list is used to store the cached data of the SST to be reclaimed.

[0156] In an exemplary embodiment, the first access list further includes other access lists; the list update module 20 is specifically used for:

[0157] If the target SST's cached data is stored in other access lists, migrate the target SST's cached data from the other access lists to the target access list.

[0158] In one exemplary embodiment, the linked list update module 20 is further configured to:

[0159] If the target SST's cached data is not stored in other access lists, query the target SST's cached data in the target access list; if not found, add the target SST's cached data to the target access list; if found, update the write time of the target SST's cached data in the target access list.

[0160] In one exemplary embodiment, the cache recycling module 30 is specifically used for:

[0161] Based on the write time of the cached data of each SST in the updated target access list, select the SST to be reclaimed from each SST in the target access list; migrate the cached data of the SST to be reclaimed to the main access list associated with the database.

[0162] In one exemplary embodiment, the cache recycling module 30 is further configured to:

[0163] Based on the write time of the cached data of each SST to be reclaimed in the updated main access list, select an SST to be reclaimed from each SST to be reclaimed as the current SST to be reclaimed; and perform the reclamation process on the cached data of the current SST to be reclaimed.

[0164] In an exemplary embodiment, the data caching processing device 1 further includes a pulse update module, wherein the pulse update module is specifically used for:

[0165] Once the access to the cached data for the currently recycled SST has ended, update the current pulse count;

[0166] Correspondingly, the cache recycling module 30 is also used for:

[0167] If an update to the current pulse count is detected, the cached data of the currently recycled SST is recycled.

[0168] In one exemplary embodiment, the linked list update module 20 is further configured to:

[0169] In response to an SST access request, if it is determined that the SST corresponding to the SST access request is an SST currently being recycled, the cached data of the SST corresponding to the SST access request is regenerated and added to the access list of the thread corresponding to the SST access request; if it is determined that the SST corresponding to the SST access request is an SST to be recycled, the cached data of the SST corresponding to the SST access request is migrated to the access list of the thread corresponding to the SST access request.

[0170] In an exemplary embodiment, the data caching processing device 1 further includes a cache size update module, wherein the cache size update module is specifically used for:

[0171] If an increase in the cacheable amount associated with the database is detected, the SST to be cached is determined based on the increase in cache size, the historical access records of each SST in the database, and the access list of each thread at the current moment; the cached data of the SST to be cached is then added to the access list of any thread.

[0172] In one exemplary embodiment, the cache size update module is further configured to:

[0173] If a decrease in the cacheable amount associated with the database is detected, the SST reclamation amount is updated based on the amount of cache reduction.

[0174] Each module in the aforementioned data caching processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0175] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores cached data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a data caching method.

[0176] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0177] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0178] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0179] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0180] It should be noted that the data involved in this application (including but not limited to SST cache data) is all data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0181] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0182] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0183] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A data caching processing method, characterized in that, The method includes: If it is detected that the target thread accesses the target sorted string table SST in the database, determine the storage status of the cached data of the target SST in other access lists corresponding to other threads; wherein, the access list corresponding to each thread is located in the local storage space of the thread and is used to store the cached data of the SST accessed by the thread. Based on the storage situation and the cached data of the target SST, the first access list is updated; wherein, the first access list includes at least the target access list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access list; Based on the updated cached data of each SST in the target access list, the main access list associated with the database is updated, and the cached data of the SST is recycled based on the updated main access list; wherein, the main access list is used to store the cached data of the SSTs to be recycled.

2. The method according to claim 1, characterized in that, The first access list also includes other access lists; updating the first access list according to the storage situation and the cached data of the target SST includes: If the target SST's cached data is stored in the other access list, the cached data of the target SST in the other access list is migrated to the target access list.

3. The method according to claim 1, characterized in that, The step of updating the first access list based on the storage status and the cached data of the target SST includes: If the storage condition is that the cached data of the target SST is not stored in the other access list, the cached data of the target SST is queried in the target access list; If the target SST is not found, add the cached data of the target SST to the target access list; If the query is successful, the write time of the cached data of the target SST in the target access chain is updated.

4. The method according to any one of claims 1-3, characterized in that, The step of updating the main access list associated with the database based on the cached data of each SST in the updated target access list includes: Based on the write time of the cached data of each SST in the updated target access list, select the SST to be reclaimed from each SST in the target access list; The cached data of the SST to be reclaimed is migrated to the main access list associated with the database.

5. The method according to any one of claims 1-3, characterized in that, The process of reclaiming SST cached data based on the updated main access list includes: Based on the write time of the cached data of each SST to be reclaimed in the updated main access list, select the SST to be reclaimed from each SST to be reclaimed, and use it as the current SST to be reclaimed. The cached data of the currently recycled SST is recycled.

6. The method according to claim 5, characterized in that, After determining the SST to be reclaimed from the SSTs to be reclaimed, the method further includes: Once the access to the cached data for the currently recycled SST has ended, the current pulse count is updated. Accordingly, the process of reclaiming the cached data of the currently reclaimed SST includes: Upon detecting an update to the current pulse count, the cached data of the currently recycled SST is recycled.

7. The method according to claim 5, characterized in that, The method further includes: In response to an SST access request, if it is determined that the SST corresponding to the SST access request is an SST in the currently recycled SST, the cache data of the SST corresponding to the SST access request is regenerated, and the cache data of the SST corresponding to the SST access request is added to the access list of the thread corresponding to the SST access request. If it is determined that the SST corresponding to the SST access request is an SST in the SST to be reclaimed, the cached data of the SST corresponding to the SST access request is migrated to the access list of the thread corresponding to the SST access request.

8. The method according to any one of claims 1-3, characterized in that, The method further includes: If an increase in the cacheable amount associated with the database is detected, the SST to be cached is determined based on the increase in cache, the historical access records of each SST in the database, and the access list of each thread at the current moment. Add the cached data of the SST to be cached to the access list of any thread.

9. The method according to claim 5, characterized in that, The method further includes: If a decrease in the cacheable amount associated with the database is detected, the SST reclamation amount is updated according to the amount of cache reduction.

10. A data caching processing apparatus, characterized in that, The device includes: The storage detection module is used to determine the storage status of cached data of the target SST in other access lists corresponding to other threads when the target thread accesses the target sorted string table SST in the database; wherein, the access list corresponding to each thread is located in the local storage space of the thread and is used to store the cached data of the SST accessed by the thread. The linked list update module is used to update the first access linked list according to the storage situation and the cached data of the target SST; wherein, the first access linked list includes at least the target access linked list corresponding to the target thread, and the cached data of the target SST exists only in the updated target access linked list; The cache reclamation module is used to update the main access list associated with the database based on the updated cache data of each SST in the target access list, and to reclaim the cache data of the SSTs based on the updated main access list; wherein, the main access list is used to store the cache data of the SSTs to be reclaimed.

11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.