Data recovery method and device of cache system, storage medium and electronic equipment
By starting a new node and loading backup data in parallel when the caching system fails, the problem of long recovery time in traditional caching systems is solved, achieving fast response and high availability, and ensuring service continuity.
Patent Information
- Application Number
- CN202511009981.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-11-25
AI Technical Summary
Traditional caching systems employ cold recovery techniques after a failure, which results in long data loading times, service interruptions, and negative impacts on user experience and backend database performance.
Under the condition that the cache system node is started, a new cache system node is started, and the backup data set is written into the cache memory. It receives read and write requests and searches for target data in memory. Missing data is read from the database into memory, realizing the parallelization of the data recovery process and system operation.
It reduces downtime during fault recovery, improves system availability and continuity during faults, ensures that client requests can be responded to even when data is not fully recovered, and avoids prolonged service interruptions.
Smart Images

Figure CN121008958A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data recovery, in particular to a data recovery method and device of a cache system, a storage medium and an electronic device. BACKGROUND
[0002] In an increasingly digital environment, data cache systems, as key components for improving data access efficiency and reducing database burden, their high availability and rapid recovery capability are crucial to guarantee service continuity.
[0003] However, the traditional cache system adopts cold recovery technology after a failure, that is, the system needs to be completely loaded with backup data before providing services externally when restarting. Although this recovery method can ensure the integrity of the data, when the data volume is large, the time-consuming of parsing and loading backup data is long, which leads to service interruption, and the user experience is reduced, and at the same time, it causes great pressure on the backend database, affecting its performance and stability. That is, the cache system data recovery method provided by the related technology has the problem of low cache system performance. In view of the above problems, currently no effective solution has been proposed. SUMMARY
[0004] The embodiments of the present application provide a cache system data recovery method and device, a storage medium and an electronic device to at least solve the technical problem of low cache system performance of the cache system data recovery method provided by the related technology.
[0005] According to an aspect of an embodiment of the present application, a cache system data recovery method is provided, comprising: starting a new cache system node and writing a backup data set into the cache memory corresponding to the cache system node in the case of meeting the cache system node starting condition; receiving a read-write request for target data and searching for the target data in the cache memory; in the case that the target data does not exist in the cache memory, reading the target data from the database to the cache memory and executing the read-write request on the target data in the cache memory.
[0006] According to another aspect of an embodiment of the present application, a cache system data recovery device is also provided, comprising: a backup data writing unit configured to start a new cache system node and write a backup data set into the cache memory corresponding to the cache system node in the case of meeting the cache system node starting condition; a data searching unit configured to receive a read-write request for target data and search for the target data in the cache memory; a data reading unit configured to read the target data from the database to the cache memory in the case that the target data does not exist in the cache memory, and execute the read-write request on the target data in the cache memory.
[0007] Optionally, the backup data writing unit comprises: a first backup data writing module, configured to write a first backup data set into the cache memory, wherein the first backup data set is used to indicate a plurality of first backup data corresponding to the cache system, and the first backup data set is used to indicate backup data of the cache data in the cache memory corresponding to the cache system at a target time point; and a second backup data writing module, configured to write a second backup data set into the cache memory, wherein the second backup data set is used to indicate an update state of the first backup data in the first backup data set between the target time point and a current time point.
[0008] Optionally, the first backup data writing module is further configured to: search for the first backup data in the first backup data set in the cache memory; and in a case where the first backup data does not exist in the cache memory, determine the first backup data as the cache data and write the first backup data into the cache memory.
[0009] Optionally, the second backup data writing module is further configured to: determine first cache data corresponding to the second backup data in the cache memory; compare time information of the second backup data with time information of the first cache data; and in a case where the second backup data is update data of the first cache data, update the first cache data according to the second backup data.
[0010] Optionally, the backup data writing unit further comprises: an access frequency determining module, configured to determine an access frequency corresponding to each backup data in the backup data set; a writing sequence determining module, configured to sort each backup data according to the access frequency to obtain a data writing sequence; and a sequence writing module, configured to write the backup data set into the cache memory according to the data writing sequence.
[0011] Optionally, the writing sequence determining module is further configured to: write backup data with a non-zero access frequency into a first queue and write backup data with a zero access frequency into a second queue; sort the backup data in the first queue according to the access frequency to obtain the data writing sequence; and the sequence writing module is further configured to: write the backup data in the first queue into the cache memory according to the data writing sequence; and write the backup data in the second queue after the backup data in the first queue is written into the cache memory.
[0012] Optionally, the access frequency determining module is further configured to: in a case where a read-write request for the cache data in the cache memory is received, increase an access frequency corresponding to the accessed cache data by one.
[0013] According to a further aspect of the embodiments of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is configured to perform the data recovery method of the cache system when executed.
[0014] According to a further aspect of the embodiments of the present application, a computer program product is provided, and the computer program product comprises computer programs / instructions stored in a computer readable storage medium. A processor of a computer device reads the computer programs / instructions from the computer readable storage medium, and the processor executes the computer programs / instructions, so that the computer device performs the data recovery method of the cache system.
[0015] According to a further aspect of the embodiments of the present application, an electronic device is provided, and the electronic device comprises a memory and a processor. The memory stores a computer program, and the processor is configured to perform the data recovery method of the cache system by using the computer program.
[0016] In the embodiments of the present application, when the cache system node startup condition is met, a new cache system node is started, and the backup data set is written into the cache memory corresponding to the cache system node. A read / write request for target data is received, and the target data is searched in the cache memory. When the target data does not exist in the cache memory, the target data is read from the database to the cache memory, and the read / write request is executed on the target data in the cache memory. By parallelizing the data recovery process and the cache system running, the cache system can be used immediately when it is started, and the backup data is loaded asynchronously in the background. This effectively reduces the interruption time of the system during the fault recovery process, especially for large data recovery scenarios, which can significantly reduce the total time consumption of data recovery. Even if the data has not been completely recovered, the cache system can immediately start responding to the read / write requests of the client, avoiding the situation that the service is unavailable for a long time in the traditional recovery process, and improving the availability and continuity of the system during the fault recovery. Therefore, the above method solves the technical problem of the cache system data recovery method provided by the related art that the cache system has low performance. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings, which are included to provide a further understanding of the present application and constitute a part of this application, illustrate embodiments of the present application and explain the principles of the present application, and do not limit the present application in any way. In the drawings:
[0018] Figure 1 FIG. 1 is a schematic diagram of a hardware environment of an optional data recovery method of a cache system according to the embodiments of the present application;
[0019] Figure 2is a flow chart of a data recovery method of an optional cache system according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of a data recovery method of an optional cache system according to an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of a data recovery method of an optional cache system according to an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of a data recovery method of an optional cache system according to an embodiment of the present application;
[0023] Figure 6 is a schematic diagram of a data recovery device of an optional cache system according to an embodiment of the present application;
[0024] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative work should fall within the protection scope of the present application.
[0026] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to the process, method, product or device.
[0027] According to an aspect of an embodiment of the present application, a data recovery method of a cache system is provided. As an optional implementation, the above-mentioned data recovery method of the cache system can be applied to, but is not limited to, a data recovery method of a cache system as shown in Figure 1The data recovery system of the cache system in the shown hardware environment. Wherein, the data recovery system of the cache system can include but is not limited to the terminal device 102, the network 110, the server 112, the database 114. The cache system runs in the server 112, which can be a centralized cache server or one or more servers in a server cluster. The terminal device 102 includes a display 108, a processor 106 and a memory 104. In addition, the server 112 includes a processing engine 116 for performing storage or read operations on the database 114. Specifically, the processing engine 116 reads data from the database 114.
[0028] Assume Figure 1 The terminal device 102 in the above-mentioned runs a program for reading cache data, and the specific process of the embodiment is as follows: as step S102, if the cache system node detects a failure, the server 112 starts a new cache system node and loads backup data. After receiving the operation instruction of the user, the terminal device 102 can execute step S104 to send a read-write request for target data to the server 112 through the network 110. Then the server 112 can execute steps S106-S108 to search for the target data in the cache memory, and if the target data does not exist in the cache memory, read the target data from the database into the cache memory.
[0029] Optionally, in the embodiment, the terminal device 102 can be a terminal device configured with a target program, and can include but is not limited to at least one of the following: a mobile phone (such as an Android mobile phone, an iOS mobile phone, etc.), a notebook computer, a tablet computer, a palm computer, a MID (Mobile Internet Device), a PAD, a desktop computer, a smart television, etc. The client can be a video client, a browser client, etc. The above-mentioned network can include but is not limited to a wired network and a wireless network, wherein the wired network includes a local area network, a metropolitan area network and a wide area network, and the wireless network includes Bluetooth, WIFI and other wireless communication networks. The above-mentioned server can be a single server, a server cluster composed of multiple servers, or a cloud server. The above-mentioned is only an example, and the embodiment does not make any limitation on this.
[0030] Optionally, in the embodiment, the data recovery method of the cache system can be applied to the cache system corresponding to the video client, but is not limited thereto. The video client can obtain the cache data such as popular video information and preferences in the cache system through the video recommendation engine. In a high-concurrency access environment, it is extremely critical to ensure the stability and response speed of the cache system. Through the data recovery method of the cache system, when the cache system detects a fault, a new node is started immediately, and the new node can respond to the read-write request of the client without immediately loading full data. Through the intervention of the proxy layer, the request for hot data is processed preferentially, avoiding the long interruption of services during the waiting period for data recovery. Not only does the data recovery method solve the performance bottleneck of the cache system during fault recovery, but also significantly improves the user experience. The requests of users in the peak period can be responded to in time, and the recommendation and playing of popular videos are almost not affected by the fault of the cache system, ensuring the smoothness and attractiveness of the platform.
[0031] In the embodiment of the application, in the case where the cache system node startup condition is met, a new cache system node is started, and the backup data set is written into the cache memory corresponding to the cache system node; a read-write request for target data is received, and the target data is searched in the cache memory; in the case where the target data does not exist in the cache memory, the target data is read from the database to the cache memory, and the read-write request for the target data is executed in the cache memory. By parallelizing the data recovery process and the cache system operation, the cache system can be used immediately when it is started, and the backup data is loaded asynchronously in the background. This effectively reduces the interruption time of the system during the fault recovery process, especially for large data recovery scenarios, which can significantly reduce the total time consumption of data recovery. Even if the data has not been completely recovered, the cache system can immediately start responding to the read-write request of the client, avoiding the long service unavailability in the traditional recovery process, and improving the availability and continuity of the system during fault recovery. Thus, the above method solves the technical problem of low cache system performance in the related art data recovery method of the cache system.
[0032] As an optional implementation, as shown in Figure 2 The data recovery method of the cache system includes the following steps:
[0033] S202, in the case where the cache system node startup condition is met, a new cache system node is started, and the backup data set is written into the cache memory corresponding to the cache system node;
[0034] It should be noted that the cache system node can be a functional unit in the cache system that can independently provide data caching and retrieval services. In a distributed system, in order to improve performance and availability, the cache system is usually composed of multiple cache nodes, and each node undertakes part of the cache task.
[0035] The startup condition can refer to the minimum operating requirements or standards required for the new node in the cache system fault recovery scenario, such as sufficient memory, disk space, network connectivity, etc.
[0036] The backup data set can be a historical data snapshot periodically saved by the cache system, containing full data and incremental update data. The cache memory can be a physical memory area on the cache system node for storing data. Cache data is stored in memory to provide high-speed data access services.
[0037] In an optional implementation, unlike the cold start recovery of the traditional cache system, the data recovery method of the present application enables the new cache node as soon as the basic startup condition is met, so that it can respond to the client's request as soon as possible. At the same time, the backup data set is loaded and written into the cache memory of the new node asynchronously, which avoids the traditional mode of waiting for the data to be completely loaded before starting to serve. This process not only reduces the service interruption time, but also optimizes the efficiency of data recovery through techniques such as segmented loading and priority sorting, ensuring the availability and performance of the system during recovery.
[0038] Suppose a video platform uses Redis (a kind of in-memory database) as its cache system. After the main node fails, the system will perform the following steps:
[0039] In the case of the main cache node being detected as down, the system automatically triggers the fault recovery process, checks the available backup data set and the resource status of the standby node. After confirming that the resources of the standby node meet the startup condition (for example, there are sufficient memory resources), the system immediately starts a new cache system node (which can be a new instance on a physical server or a virtual node in a cloud environment).
[0040] The system asynchronously writes the backup data set (containing full data and incremental update files) into the cache memory of the new node. The technical means used here can include: using an analysis tool to block the backup data by key range, forming multiple data streams, each of which can be processed in parallel, speeding up the data recovery rate. Implement a recovery strategy based on heat, collect hot key information through an agent, and write hot data into the cache memory first, and then write non-hot data. The specific process of writing the backup data set will be described in detail later, and will not be repeated here.
[0041] The new node starts serving immediately after it goes online, even if not all data has been loaded at this time. Client requests can be processed normally, and for data that has not been recovered, the system will obtain it from the database or other healthy nodes and cache it for subsequent use.
[0042] The cache system node can take one of the following forms:
[0043] Physical server: Start a new physical server as a cache node within the data center.
[0044] Virtual machine instance: Create a new virtual machine instance on a cloud platform to run as a cache node.
[0045] Container instance: Use container technology to quickly deploy a cache node, such as using Docker container services.
[0046] S204, receive read and write requests for target data, and search for target data in cache memory;
[0047] It should be noted that the target data can refer to frequently accessed hot data, or any data that needs to be prioritized or loaded during the cache system restart and data recovery process. Read and write requests can be client requests to the cache system, including reading data (query) and writing data (update or add). Cache memory can be a memory area in the cache system for storing data, designed to quickly respond to read and write requests and reduce dependence on the backend database. The search can be a process of searching for target data in cache memory to respond to client read and write requests.
[0048] In an optional implementation, when the cache system starts, it will start to accept client read and write requests even if the data has not been completely recovered. For these requests, the system will try to find the target data in the cache memory. If found, return or update directly; if not found, handle according to specific strategy (such as checking the write mechanism), which may load from the database or mark as data to be recovered.
[0049] In the traditional cold recovery process, the system must wait until all backup data is loaded before providing services, which will cause a long service interruption. In the recovery mode of the present application, the newly started cache system node immediately opens the service and receives client read and write requests. Although the data in the cache memory may not be complete at this time, the system will try to respond to these requests, and for data already in the cache, it can be processed immediately; for data that has not been recovered, the system takes action according to the strategy, such as returning cache miss, prompting the client to obtain from the database, or listing the loading of the data as a high-priority recovery operation.
[0050] In an optional implementation, in the case of receiving read and write requests, it can also be checked whether the target data in the cache system is completely recovered, where complete recovery can refer to the recovery of full data and incremental data. It can also be preliminary recovery of target data, i.e. only full data is recovered.
[0051] Suppose a video platform's video recommendation engine is using a caching system that quickly starts a hot recovery process after an accidental failure. The S204 step in this process is:
[0052] When the caching system restarts, it immediately starts listening to read and write requests from clients (such as video playback frontends). A client sends a read request to obtain the rating information of a popular TV series. The system searches for the data item of this rating information in the cache memory. At this time, due to the high priority strategy of hot recovery, the system may have considered the data related to the popular TV series as hot data and loaded it preferentially in the early stage of the recovery process. If the rating information is already in the cache memory, the system can quickly return the result, and the client experience is almost unaffected. If the rating information has not been loaded into the cache memory (possibly because the hot recovery process has not completed the processing of this data), the system will mark this request as a cache miss.
[0053] S206, in the case where the target data does not exist in the cache memory, read the target data from the database to the cache memory, and execute the read and write request on the target data in the cache memory.
[0054] It should be noted that the cache memory refers to the memory area in the caching system for temporarily storing data, with the purpose of quickly responding to users' read and write requests and reducing the load on the backend database. The database can be a place for storing data persistently, with high data integrity and reliability, but the response speed is slower when reading and writing large amounts of data.
[0055] In an optional implementation, when the client's request points to data that does not yet exist in the cache memory, the caching system does not directly return empty, but instead turns to the backend database to read the required "target data" and loads these data into the cache memory. Once the target data is loaded into the cache memory, future read and write requests for this data will directly act on the cache memory, without the need to access the database, thereby improving the response speed of data access and reducing the load on the database.
[0056] In the early stage of system startup or data loading, not all data will immediately exist in the cache memory, especially those hot data that were frequently accessed before the failure. To make up for this gap, the caching system adopts a "database backfilling" strategy - when it detects that the cache memory is missing data, it actively obtains these data from the database and puts them into the cache, so that subsequent requests can be read directly from the cache memory without the need to access the database again, ensuring the consistency of cache data and database data.
[0057] As mentioned above, assuming that some user high-frequency access video metadata in the cache memory has not been recovered after the recovery of the recommendation engine cache system of a certain video platform. At this time, a user attempts to access the detailed information of a popular TV series, but the cache memory does not find this data. According to the logic of step S206, the system automatically reads the metadata of the TV series from the database into the cache memory and updates the cache memory to make it the latest data source.
[0058] Subsequent user access to target data will be directly read from the cache memory without accessing the database until the data needs to be updated or evicted from the cache. This process ensures that the cache system can efficiently respond to user needs even in the initial recovery phase and gradually build a complete cache data set to provide faster and more stable service experience for users. In this way, the cache system can still provide stable service even when the data has not been completely recovered, especially for high-frequency access hot data for priority processing, greatly enhancing the flexibility of the system and the satisfaction of users. At the same time, this also reduces the pressure on the database and improves the overall efficiency of the system.
[0059] In the embodiments of the present application, under the condition that the cache system node startup condition is met, a new cache system node is started, and the backup data set is written into the cache memory corresponding to the cache system node; a read-write request for target data is received, and the target data is searched in the cache memory; in the case that the target data does not exist in the cache memory, the target data is read from the database to the cache memory, and the read-write request for the target data is executed in the cache memory. By parallelizing the data recovery process and the cache system operation, the cache system can be used immediately when it is started, while the backup data is loaded asynchronously in the background. This effectively reduces the interruption time of the system during the fault recovery process, especially for large data recovery scenarios, which can significantly reduce the total time consumption of data recovery. Even if the data has not been completely recovered, the cache system can immediately start responding to the read-write requests of the client, avoiding the situation that the service is unavailable for a long time in the traditional recovery process, and improving the availability and continuity of the system during the fault recovery period. Thus, the above method solves the technical problem of low cache system performance in the related art cache system data recovery method.
[0060] In an optional embodiment, writing the backup data set into the cache memory corresponding to the cache system node comprises: writing a first backup data set into the cache memory, wherein the first backup data set is used to indicate a plurality of first backup data corresponding to the cache system, and the first backup data set is used to indicate backup data of cache data in the cache memory corresponding to the cache system at a target time point; and writing a second backup data set into the cache memory, wherein the second backup data set is used to indicate an update status of the first backup data in the first backup data set between the target time point and a current time point.
[0061] It should be noted that the backup data set can refer to the backup of the data in the cache memory by the cache system at a certain time point, which can be divided into full data and incremental data.
[0062] The first backup data set specifically refers to the full data backup at a target time point before the fault occurs, which contains all the cache data in the cache memory at that time. The second backup data set refers to the update record of the first backup data set by the cache system between the target time point and the current time point, i.e. incremental data, which reflects the data changes in this period of time.
[0063] In an optional embodiment, the system writes all data in the first backup data set into the cache memory, which is equivalent to restoring the state of the cache memory at the target time point. Then, the system loads the second backup data set, which contains the data changes after the target time point, i.e. the update status of the full data. The combination of full data and incremental data forms a complete data set, so that the cache system can timely reflect all data changes before and after the fault, and ensure the timeliness and consistency of the cache data.
[0064] The first backup data set (full data) refers to all data in the data set at a certain time point. In data backup, full backup is a strategy that copies all data at each backup, whether it is newly generated or previously existing. This backup method ensures the integrity of the backup and can be used to restore the entire system state to the state at the backup time, but the disadvantage is that it occupies a large storage space and takes a long time to backup and restore.
[0065] The second backup data set (incremental data) refers to the newly generated or modified data in the system since the last backup. In data backup, incremental backup is a more efficient strategy that only backs up the data that has changed since the last backup (whether it is a full backup or an incremental backup). This way greatly reduces the time and storage space required for backup, but using incremental backup alone requires combining a certain full backup to restore the complete data when restoring the data, because the incremental backup does not contain the unchanged old data.
[0066] In optional embodiments, in the fault recovery of the cache system, a combination of the first backup data set and the second backup data set is usually used for recovery. The first backup data set is recovered first to quickly establish the basic state of the cache, and then the second backup data set is loaded to update the latest changed information in the cache.
[0067] Suppose that the user behavior analysis system of a video platform encounters an unexpected failure at a certain time during operation and needs to perform data recovery. The system first calls the full data recovery mechanism to load the first backup data set of the target time point (for example, the full data snapshot of the previous day at dawn) from the backup storage and quickly write it into the cache memory of the newly started cache system node. Next, the system loads and processes the second backup data set from the target time point to the failure occurrence through the incremental data recovery mechanism. This part of data records the changes of the full data, such as user behaviors of watching new videos, real-time update information such as comments or likes, etc.
[0068] Through the above-mentioned embodiments of the present application, the cache system node not only quickly rebuilds the data in the cache memory, but also maintains the latest state of the data through incremental update, ensuring the correctness and efficiency of subsequent service requests. This system plays an important role in fault recovery, avoiding long-term business interruption, and optimizing the efficiency of data recovery through parallel and priority mechanisms, reducing recovery time and database pressure, and ultimately improving user experience and overall system availability.
[0069] In optional embodiments, writing the first backup data set into the cache memory includes: finding the first backup data in the first backup data set in the cache memory; and in the case that the first backup data does not exist in the cache memory, determining the first backup data as cache data and writing it into the cache memory.
[0070] It should be noted that the first backup data can be each data entry in the first backup data set, representing one or a group of related data in the cache memory.
[0071] In optional embodiments, before writing the first backup data, the existence of the data in the cache memory needs to be found. This process ensures that there is no repeated writing of existing data. If the corresponding first backup data is not found in the cache memory, it means that this part of data is missing or has been cleaned up during fault recovery and needs to be recovered from the first backup data set. After confirming that the data does not exist in the cache memory, it is marked as cache data and written into the cache memory to rebuild the complete cache data set.
[0072] In optional embodiments, to improve the overall efficiency of data recovery, a block processing and parallel parsing approach can be adopted. The first backup data set is divided into multiple data blocks according to a predetermined rule, such as range division based on the hash value of the data key. In this way, a large data recovery task can be divided into multiple smaller, independently processable tasks, facilitating parallel processing. Multi-threading or multi-processing technology can be used to simultaneously parse multiple data blocks. Each thread or process is responsible for processing one or more data blocks, converting JSON or other format data into internal cache system structures, and achieving fast data loading. After parsing, the data blocks are written to the cache memory in parallel. Here again, multi-threading technology can be used, with each thread responsible for writing a data block to the cache, greatly speeding up data loading.
[0073] In optional embodiments, data can be divided by key or range. In cache system and database management, "key" and "range" are two common data block and index strategies used to optimize data storage, retrieval, and recovery processes.
[0074] In key-value pair storage systems such as Redis, Memcached, etc., data is stored in the form of key-value, where "key" refers to the key used to uniquely identify the data. In block processing, dividing by "key" means dividing the data set into multiple subsets according to different parts or attributes of the key. For example, if the data key is a combination of user ID and video ID (such as "user123_movie456"), the system may divide it by user ID or video ID, allowing faster positioning and parallel processing during data recovery or retrieval.
[0075] Dividing by "range" means dividing data according to the range of data values. This is usually applicable to numerical type data such as timestamps, ID numbers, etc. In the context of data recovery, dividing by "range" of timestamps can divide data by time period, allowing data to be gradually pushed from early data to the latest data during recovery, or distributing data blocks according to CPU core numbers to achieve load balancing and parallel processing. For example, an incremental data file may contain data updates for the past week, and the system can divide it into 7 blocks corresponding to each day of the week, allowing multiple threads or processors to handle parallel processing during parsing and recovery, greatly improving efficiency.
[0076] In an optional example, assuming that a live channel recommendation system of a certain video platform uses Redis as a cache system, after experiencing a server failure, the first backup data set (full data) is divided into several data blocks according to the hash value of the data key, for example, the data with key values in the range of 0-10000 constitutes a block, the data with key values in the range of 10001-20000 constitutes another block, and so on. The multi-threading capability of a four-core CPU can be used to simultaneously start four parsing threads, and each thread is responsible for parsing a data block. The parsing thread converts the JSON data into a structure recognizable by Redis. At the same time of parsing, the cache system starts a new node and checks that the write mechanism is activated. The new node starts to find the data in the first backup data set in the cache memory, and for the data that does not exist, the parsed data block is written into the cache memory to realize parallel loading of data.
[0077] Through the above-mentioned embodiments of the present application, through parallel processing, the overall time of data recovery is significantly shortened, especially when the data volume is huge, the advantage of block parallel parsing is more significant. The new node provides services immediately after starting, and even in the early stage of data recovery, it can also process part of the cache miss requests, avoiding service interruption. The check-write strategy ensures the uniqueness of the data and avoids repeated writing, thereby improving the efficiency of writing the cache memory and saving memory resources.
[0078] In an optional embodiment, writing the second backup data set into the cache memory includes: determining the first cache data corresponding to the second backup data in the second backup data set in the cache memory; comparing the time information of the second backup data and the time information of the first cache data; in the case that the second backup data is the update data of the first cache data, updating the first cache data according to the second backup data.
[0079] It should be noted that the second backup data can be a single data item in the second backup data set, representing an update record of a certain data item in the cache memory. The first cache data can be an existing data item in the cache memory, corresponding to a certain update object in the second backup data. The time information is used to identify the latest state of the data item, which is usually the timestamp of data modification, used to determine which version of data is the latest and valid.
[0080] In an optional embodiment, the system first identifies each incremental data in the second backup data set and determines the corresponding first cache data in the cache memory. This correspondence can be achieved by matching the key values. Next, the system compares the time information of the second backup data with the time information of the first cache data to determine the update status of the data. The time information here is usually a timestamp that identifies the modification time of the data, helping the system determine which version of the data is the latest and valid. If it is found that the time information in the second backup data is later than that in the first cache data, it means that the second backup data is an updated version of the first cache data, and the system will perform an update operation to write the content of the second backup data into the first cache data, thereby ensuring that the data in the cache memory remains up-to-date. This process is usually accompanied by a check-write operation to avoid unnecessary data writing while ensuring data version consistency.
[0081] In an optional embodiment, a version number or timestamp can be attached to each data item to identify the latest state of the data. During data recovery, each data item should carry its version information. Before writing data, the recovery program needs to check the data version of the corresponding key in the cache system. If there is already data in the cache and its version number is newer than the recovery data, the recovery program will skip writing to avoid overwriting updated data.
[0082] In an optional embodiment, a separate parsing thread can be used to process the second backup data set (incremental data), which can ensure the continuity and consistency of the parsing process. This is because incremental data usually needs to be parsed in a certain order to correctly reflect the update history of the data and avoid data confusion or loss problems that may be introduced by concurrent parsing. The parsing thread is responsible for reading the incremental data from the file, converting JSON or other storage formats into a format that can be directly processed by the cache system, and may also perform some preprocessing such as data verification, format conversion, etc. to ensure the integrity and accuracy of the data.
[0083] After parsing the incremental data, multiple recovery threads work in parallel to write data into the cache system. This parallel processing mechanism fully utilizes the capabilities of modern multi-core processors, greatly speeding up the data recovery process, especially for large data sets, which can significantly shorten the time required for recovery. The parsed incremental data items are hashed according to their keys, and then distributed to different recovery thread queues according to the hash results. This strategy ensures that different data items are evenly distributed to various recovery threads, avoiding the situation where one thread is excessively busy while others are idle, thereby improving overall resource utilization and recovery efficiency.
[0084] In an optional example, it is assumed that the video recommendation system cache node of a certain video platform needs to be recovered from failure, which involves the write operation of the second backup data set. The incremental data file (second backup data set) is parsed, each update record (second backup data) is identified, and hash mapping is performed through the data key to find the corresponding record (first cache data) in the cache memory. For each second backup data, the system extracts its timestamp and compares it with the timestamp of the corresponding first cache data in the cache memory. For example, for the update record of user A's rating of video B, the system checks the rating record in the current cache memory and compares the last modification time of the two. If it is found that the update time of user A's rating of B is later than the time in the cache memory, it means that the user has performed a new rating operation, and the system will update the old rating information in the cache memory with the new rating data to ensure that the data in the cache memory is the latest. The update operation follows the check-write mechanism, and only when it is determined that the new data is updated will the write action be performed, avoiding data conflicts and redundant writing.
[0085] Through the above-mentioned embodiments of the present application, when writing the second backup data set to the cache memory, not only the data update logic is considered, but also the parallel recovery technology and the check-write mechanism are introduced, which effectively improves the accuracy and efficiency of incremental data recovery. In this way, not only the availability of the cache system can be quickly recovered, but also the timeliness and consistency of the data in the cache memory can be ensured, thereby improving the overall performance and user experience of the system.
[0086] In an optional embodiment, writing the backup data set to the cache memory corresponding to the cache system node comprises: determining the access times of each backup data in the backup data set; sorting each backup data according to the access times to obtain a data write order; and writing the backup data set to the cache memory according to the data write order.
[0087] It should be noted that the backup data can be any data item in the backup data set, and each data item corresponds to specific cache data in the cache memory. The access times can be the total number of times a certain data item is read or written within a certain period, reflecting the popularity and importance of the data item. The data write order can be an execution sequence for writing the cache memory according to the access times of the backup data.
[0088] In an optional embodiment, the system can count the number of accesses of each backup data item in the past period of time through the access log recorded by the proxy layer or similar mechanisms. This step is the basis for sorting and helps to identify which data is the hotspot data that users access most frequently. Based on the number of accesses obtained in the first step, the system ranks all backup data items in descending order to form a data write order list. This means that the more frequently accessed data has a higher priority for writing into the cache memory. The system loads the data items in the backup data set into the memory of the cache system in order according to the sorted data write order. This strategy ensures that the data that users access most frequently can be recovered first, thereby maximizing user demand in the initial stage of system recovery, reducing access frequency to the backend database, and improving the overall response speed and availability of the system.
[0089] In an optional example, assume that the video recommendation service of a video platform encountered a cache failure within a day and needs to perform data recovery. The server decides to use an access frequency-based sorting strategy to recover the cache data. First, the system can analyze the user behavior data in the past week to determine the number of accesses of each data item (such as the metadata associated with the ID of each movie). Assume that the "recently popular drama" data item has the highest number of accesses, followed by the "classic movie" data item. According to the number of accesses, the system ranks the data of the "recently popular drama" first, followed by the data of the "classic movie", and then other data items with lower access frequencies. When recovering, the system loads the data of the "recently popular drama" into the cache memory first, followed by the data of the "classic movie", and finally the other data. This process ensures that high-frequency access data can be quickly recovered, so that even in the initial stage of data recovery, the system can quickly respond to the requests of most users, significantly improving the user experience.
[0090] Through the above embodiments of the present application, stable services can be provided in the early stage of failure recovery, while the user experience and business continuity are guaranteed by prioritizing the recovery of hotspot data.
[0091] In an optional embodiment, the data write order is obtained by sorting the backup data according to the number of accesses, including: writing backup data with a number of accesses other than 0 into a first queue, and writing backup data with a number of accesses of 0 into a second queue; sorting the backup data in the first queue according to the number of accesses to obtain the data write order;
[0092] In an optional embodiment, the backup data set is written into the cache memory according to the data write order, including: writing the backup data in the first queue into the cache memory according to the data write order; and writing the backup data in the second queue when the backup data in the first queue is written.
[0093] It should be noted that the first queue can be a high-priority queue, which is used to store hot data with access frequency higher than a certain threshold, so as to be processed preferentially during data recovery. The second queue can be a low-priority queue, which is used to store data with access frequency of 0 or lower than the threshold of the first queue, and these data are processed after the hot data during recovery. The data writing order can be the order of writing data into the cache memory according to the access frequency or priority of the data.
[0094] In an optional embodiment, the data with access frequency other than 0 is identified as hot data and written into the first queue according to the access frequency of the data, and the data with access frequency of 0 is regarded as non-hot data and written into the second queue. The classification here is based on the query result of the Bloom filter, and the hot data will have a higher priority in the recovery process. The hot data in the first queue is further sorted according to the access frequency, and the data with higher access frequency is sorted in front, which means that these data will be processed and written preferentially during data recovery. This sorting mechanism is realized by analyzing the access frequency data recorded by the Bloom filter. During data recovery, the hot data in the first queue is sequentially taken out according to the data writing order and written into the cache memory, so as to ensure that these data become accessible quickly. When the data in the first queue is completely written, the system starts to process the non-hot data in the second queue and writes them into the cache memory.
[0095] In an optional embodiment, assuming that the cache system of the interactive entertainment board of a video platform needs to be recovered, the data recovery tool first divides the data into hot data and non-hot data based on the access frequency statistical result recorded by the Bloom filter.
[0096] The data recovery tool reads the backup data set, and for each data item, first checks whether the key exists in the Bloom filter. If it exists, it means that it is a hot data with high access frequency, which is written into the first queue (high-priority queue); if the key does not exist in the Bloom filter or the access frequency is 0, it means that it is a non-hot data with low access frequency, which is written into the second queue (low-priority queue). Subsequently, the tool sorts the hot data in the first queue according to the access frequency, so that the data with the highest access frequency is ranked first in the queue, so that these data will be processed and written into the cache memory preferentially during data recovery. When the data recovery starts, the tool writes the hot data in the first queue into the cache memory according to the sorted writing order. Since the data in the first queue are all hot data, this process can significantly improve the response ability and user experience of the cache system during recovery. When all the data in the first queue are written, the tool starts to process the non-hot data in the second queue and writes them into the cache memory.
[0097] Through the above-mentioned embodiments of the present application, the cache system can quickly recover the access of hot data in the fault recovery process, greatly reducing the service interruption time, improving the business continuity and user satisfaction. At the same time, the non-hot data is written into the cache in a predetermined order without affecting the user experience, ensuring the comprehensiveness of data recovery and system stability.
[0098] In an optional embodiment, before determining the access times corresponding to each backup data in the backup data set, the method comprises: in the case of receiving a read / write request for cache data in the cache memory, increasing the access times corresponding to the accessed cache data by one.
[0099] It should be noted that the agent can be an intermediate layer located between the client and the cache system, responsible for managing and controlling the read / write requests of data, and collecting hot data information. The class Bloom filter counter can be based on the principle of Bloom filter, but with statistical function added to record the access frequency of cache key, helping to identify hot data.
[0100] In an optional embodiment, when the agent receives a cache data read / write request from the client, the access times of the target cache data of the request are counted incrementally. This step is automatically executed after each request processing without manual intervention. The increase of access times reflects the popularity of cache data, i.e. the degree of frequent access of data. This helps to prioritize hot data in data recovery, reducing the impact of service interruption.
[0101] In an optional embodiment, assume that the live channel recommendation system of a certain video platform records all the passed client requests during operation to understand which video metadata are the most frequently accessed hot data by users.
[0102] When the client (such as a user browser) first requests to obtain the metadata of video “A”, the agent records this access and increases the count of the key of “A” in its class Bloom filter counter. As time goes by, the video page of “A” is frequently accessed, and the agent server continuously receives requests for the same metadata and constantly increases the access times of the corresponding data item in the counter. The agent server regularly summarizes the data access information in its counter and sends it to the management module of the cache system. The management module identifies the metadata of “A” and other data items with high access times as hot data according to the access times and a preset threshold. When the cache system encounters a fault and needs to be hot recovered, the management module passes the identified hot data list (based on the class Bloom filter counter) to the recovery program. The recovery program prioritizes the recovery of these high access frequency data items from the backup data set to the cache memory according to the hot data list, ensuring that the most frequently accessed data can be immediately available after the system restarts.
[0103] Through the above-mentioned embodiments of the present application, by monitoring and counting the access times in real time through the proxy server, the system can accurately identify the hot data in time. In the fault recovery, the recovery program prioritizes the hot data according to these information, greatly reduces the time of unavailable cache system, improves the user access experience, at the same time, also reduces the pressure of the backend database, realizes the double improvement of data recovery efficiency and user experience.
[0104] Figure 3 is a schematic diagram of a data recovery method of an optional cache system according to an embodiment of the present application; in the normal operation stage, the cache system of the video platform follows a set of efficient data management and hot data identification mechanism to optimize data processing and improve system response speed. The following is the detailed process of this stage:
[0105] Users or systems send read-write requests to the cache system 306 through the client 302, which may include queries for video metadata, updating personal viewing history, obtaining recommended content, etc.
[0106] When the client requests arrive, they are first captured by the proxy layer 304. The role of the proxy layer is similar to a transit station, which handles, schedules and optimizes the requests of the client. The proxy layer uses the counter mechanism of the class Bloom filter to identify hot data. Whenever data is accessed, the proxy layer will increase the count for the corresponding data item in the class Bloom filter, which helps to dynamically monitor and predict which data is most frequently accessed by users. The identification results of these hot data will be used for priority sorting in the data recovery stage, to ensure that in the fast recovery process after the system failure, hot data can be loaded preferentially to reduce the dependence on the backend database and improve the response speed.
[0107] All read-write requests processed by the proxy layer are finally passed to the cache system 306, which stores a large amount of data, especially hot data that is frequently accessed, to improve access speed and reduce the burden on the backend database. The cache system regularly backs up data to persistent storage to form backup data 308, including a first backup data set (full data) and a second backup data set (incremental data).
[0108] Figure 4 is a schematic diagram of another data recovery method of an optional cache system according to an embodiment of the present application; when the cache system encounters a fault and needs to be recovered, the data recovery stage is started to ensure the minimum interruption time of the service and the fast availability of the data. The following is the detailed process of this stage:
[0109] The data recovery tool 402 is a software or script designed specifically for parsing and recovering cache data. During the data recovery phase, its primary task is to parse the first backup data set (full data) and the second backup data set (incremental data) and prepare to restore the data to the cache system. The parsing process includes reading backup files, converting JSON or other complex format data into a format that can be directly written to cache memory. Then, the data recovery tool prioritizes processing those data items marked as hotspots based on the hotspot data identification provided by the agent layer, ensuring that they can be quickly loaded and recovered.
[0110] The newly started new cache system 404 is a cache system instance created or restarted after a failure occurs. It will immediately start receiving client requests and providing preliminary read-write services after starting, even if the data has not been fully recovered at this time. The data parsed by the data recovery tool 402 will be written to the cache memory of the new cache system 404, first the full data set, and then the incremental data set. This process follows the check-write mechanism to avoid repeated writing of data and maintain consistency of data versions. Hotspot data will be prioritized for writing to cache memory, ensuring that most client requests can be handled in the early stages of data recovery, reducing service interruption time.
[0111] Figure 5 is another optional data recovery method for a cache system according to an embodiment of the present application; the data recovery tool can be a software or system component specifically designed to recover cache system data from backup data, and its core function is to parse backup files and classify them according to the importance and access patterns of the data for efficient loading.
[0112] The parsing module can be a data recovery tool responsible for parsing backup data into a readable format, usually extracting data from compressed or encrypted backup files and converting it into a form suitable for processing by the cache system. The hotspot data Bloom filter can be a structure used to store hotspot data identifiers, which can help identify which are high-frequency access hotspot data, thereby optimizing the data recovery strategy.
[0113] Bloom filter merging is when there are multiple agents recording hotspot data at different time periods, the respective Bloom filters need to be merged to generate a comprehensive hotspot data Bloom filter to ensure comprehensive coverage of all hotspot data.
[0114] The high-priority queue can be used to store parsed hotspot data, which will be loaded into cache memory with high priority during data recovery. The low-priority queue can be used to store non-hotspot data, which has a lower priority for recovery and will be loaded later.
[0115] The parsing module of the data recovery tool first acquires the Bloom filter of the hotspot data from the agent, and if there are multiple agents in the system that record the hotspot data access conditions in different time periods, the Bloom filters are combined. The parsing module then starts to parse the data in the backup file, and for each parsed data item, the Bloom filter is queried according to the key value of the data item. If the key value appears in the Bloom filter, it indicates that the data item is a hotspot data item, and the parsing module puts the data item into the high-priority queue; otherwise, if the key value does not appear in the Bloom filter, the data item is a non-hotspot data item, and the data item is put into the low-priority queue.
[0116] Inside the high-priority queue and the low-priority queue, the queues are further subdivided into multiple sub-queues according to the number of recovery threads in the system. For example, if two recovery threads (thread A and thread B) are configured in the system, the high-priority queue is split into queue A and queue B, and each queue corresponds to a recovery thread. The same strategy is applied to the low-priority queue.
[0117] The recovery thread first checks whether there is data waiting for recovery in the high-priority queue, and if there is, the recovery thread immediately starts the recovery work and preferentially loads the hotspot data into the cache memory to quickly recover the service capability of the system, especially for the hotspot data with high access frequency, to reduce the number of times that the client accesses the database. Once the data in the high-priority queue is processed, the recovery thread processes the data in the low-priority queue.
[0118] It should be noted that, for the foregoing method embodiments, in order to simply describe, the method embodiments are all described as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.
[0119] According to another aspect of the embodiments of the present application, a data recovery apparatus of a cache system for implementing the data recovery method of the cache system is also provided. As shown in FIG. 6, the apparatus includes: Figure 6
[0120] The backup data writing unit 602 is configured to start a new cache system node when the cache system node startup condition is met, and write the backup data set into the cache memory corresponding to the cache system node;
[0121] The data searching unit 604 is configured to receive a read / write request for target data, and search for the target data in the cache memory;
[0122] The data reading unit 606 is configured to read the target data from the database to the cache memory and execute the read-write request on the target data in the cache memory when the target data does not exist in the cache memory.
[0123] Optionally, the backup data writing unit 602 includes a first backup data writing module configured to write the first backup data set to the cache memory, where the first backup data set is used to indicate a plurality of first backup data corresponding to the cache system, and the first backup data set is used to indicate the backup data of the cache data in the cache memory corresponding to the cache system at the target time point; and a second backup data writing module configured to write the second backup data set to the cache memory, where the second backup data set is used to indicate the update status of the first backup data in the first backup data set between the target time point and the current time point.
[0124] Optionally, the first backup data writing module is further configured to: search for the first backup data in the first backup data set in the cache memory; and determine the first backup data as the cache data and write the first backup data to the cache memory when the first backup data does not exist in the cache memory.
[0125] Optionally, the second backup data writing module is further configured to: determine the first cache data corresponding to the second backup data in the cache memory; compare the time information of the second backup data with the time information of the first cache data; and update the first cache data according to the second backup data when the second backup data is the update data of the first cache data.
[0126] Optionally, the backup data writing unit 602 further includes an access frequency determining module configured to determine the access frequency of each backup data in the backup data set; a writing sequence determining module configured to sort the backup data according to the high and low of the access frequency to obtain a data writing sequence; and a sequence writing module configured to write the backup data set to the cache memory according to the data writing sequence.
[0127] Optionally, the writing sequence determining module is further configured to: write the backup data with the access frequency of 0 to the first queue and write the backup data with the access frequency of 0 to the second queue; and sort the backup data in the first queue according to the high and low of the access frequency to obtain the data writing sequence; and the sequence writing module is further configured to: write the backup data in the first queue to the cache memory according to the data writing sequence; and write the backup data in the second queue when the writing of the backup data in the first queue is completed.
[0128] Optionally, the access frequency determining module is further configured to: add 1 to the access frequency of the accessed cache data when the read-write request on the cache data in the cache memory is received.
[0129] Optionally, in the embodiment, the implementation of each unit module can refer to the above-mentioned method embodiments, which will not be repeated here.
[0130] According to another aspect of the embodiments of the present application, an electronic device for implementing the data recovery method of the above-mentioned cache system is also provided, which can be Figure 7 the terminal device or the server as shown. The present embodiment takes the terminal device as an example to illustrate. As shown in the figure, the electronic device includes a memory 702 and a processor 704, the memory 702 stores a computer program, and the processor 704 is configured to execute the steps in any of the above-mentioned method embodiments through the computer program. Figure 7
[0131] Optionally, in the embodiment, the electronic device can be located in at least one of the network devices in the computer network.
[0132] Optionally, in the embodiment, the processor can be configured to execute the following steps through the computer program:
[0133] S1, in the case of meeting the cache system node starting condition, starting a new cache system node, and writing the backup data set into the cache memory corresponding to the cache system node;
[0134] S2, receiving the read-write request for the target data, and searching for the target data in the cache memory;
[0135] S3, in the case that the target data does not exist in the cache memory, reading the target data from the database to the cache memory, and executing the read-write request on the target data in the cache memory.
[0136] Optionally, those skilled in the art can understand that Figure 7 the structure shown in the figure is only schematic, and the electronic device can also be a terminal device such as a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a mobile Internet device (MID), a PAD, and a server, a server cluster, etc. capable of storing data. Figure 7 It does not limit the structure of the above-mentioned electronic device. For example, the electronic device can include more or less components (such as network interfaces, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 7 Figure 7
[0137] The memory 702 can be used to store software programs and modules, such as program instructions / modules corresponding to the data recovery method and device of the cache system in the embodiments of the present application. The processor 704 executes various functions and data processing by running the software programs and modules stored in the memory 702, that is, implements the data recovery method of the cache system as described above. The memory 702 can include a high-speed random access memory, and can further include a non-volatile memory such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 702 can further include a memory remotely arranged with respect to the processor 704, which can be connected to the terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. Specifically, the memory 702 can be used to store media files, but is not limited to this. As an example, as shown in Figure 7 The memory 702 can include but is not limited to the backup data writing unit 602, the data searching unit 604, and the data reading unit 606 in the data recovery device of the cache system as described above. In addition, other module units in the data recovery device of the cache system can also be included, but are not limited to this, and will not be described in detail in this example.
[0138] Optionally, the transmission device 706 is used to receive or send data via a network. Specific examples of the above-mentioned network can include wired networks and wireless networks. In one example, the transmission device 706 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers through a network cable to communicate with the Internet or a local area network. In one example, the transmission device 706 is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
[0139] In addition, the electronic device further includes a display 708 for displaying the data recovery system of the cache system, and a connection bus 710 for connecting various module components in the electronic device.
[0140] In other embodiments, the terminal device or the server can be a node in a distributed system, where the distributed system can be a blockchain system, which can be a distributed system formed by the plurality of nodes communicating through a network. The nodes can form a peer-to-peer (P2P, Peer To Peer) network, and any form of computing device, such as a server, a terminal, or an electronic device, can become a node in the blockchain system by joining the peer-to-peer network.
[0141] According to an aspect of the present application, a computer program product is provided, which includes computer programs / instructions containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by a communication part, and / or installed from a detachable medium. When the computer program is executed by a central processing unit, various functions provided by the embodiments of the present application are executed.
[0142] The above-mentioned sequence numbers of the embodiments of the present application are only for description, and do not represent advantages or disadvantages of the embodiments.
[0143] According to an aspect of the present application, a computer readable storage medium is provided, from which a processor of a computer device reads computer instructions, and the processor executes the computer instructions, so that the computer device executes the data recovery method of the above-mentioned cache system.
[0144] Optionally, in the present embodiment, the above-mentioned computer readable storage medium can be configured to store computer programs for executing the following steps:
[0145] S1, in the case of meeting the cache system node starting condition, starting a new cache system node, and writing the backup data set into the cache memory corresponding to the cache system node;
[0146] S2, receiving a read / write request for target data, and searching for the target data in the cache memory;
[0147] S3, in the case that the target data does not exist in the cache memory, reading the target data from the database to the cache memory, and executing the read / write request on the target data in the cache memory.
[0148] Optionally, in the present embodiment, it can be understood by those skilled in the art that all or part of the steps in the above-mentioned embodiments can be completed by programs instructing the hardware related to the terminal device, and the programs can be stored in a computer readable storage medium, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0149] The integrated units in the above embodiments, if implemented in the form of software function units and sold or used as independent products, can be stored in the above computer-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions to make one or more computer devices (which can be personal computers, servers or network devices, etc.) execute all or part of the steps of the above-mentioned methods of various embodiments of the present application.
[0150] In the above embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0151] In the several embodiments provided by the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the above-mentioned device embodiments are only schematic, for example, the division of the above-mentioned units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed mutual ones can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.
[0152] The units described above as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. they can be located in one place or distributed on multiple network units. Part or all of the units can be selected to achieve the purpose of the embodiment of the present application according to actual needs.
[0153] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or software function unit.
[0154] The above is only the preferred embodiment of the present application, and it should be pointed out that for those skilled in the art, without departing from the principle of the present application, some improvements and refinements can be made, which should be regarded as the protection scope of the present application.
Claims
1. A data recovery method of a cache system, characterized by, The method comprises the following steps: In the case of meeting the cache system node starting condition, starting a new cache system node, and writing a backup data set into the cache memory corresponding to the cache system node; Receiving a read-write request for target data, and searching for the target data in the cache memory; In the case that the target data does not exist in the cache memory, reading the target data from the database to the cache memory, and executing the read-write request on the target data in the cache memory.
2. The method of claim 1, wherein, The step of writing the backup data set into the cache memory corresponding to the cache system node comprises: Write the first backup data set into the cache memory, wherein the first backup data set is used to indicate a plurality of first backup data corresponding to the cache system, and the first backup data set is used to indicate the backup data of the cache data in the cache memory corresponding to the cache system at a target time point; Write the second backup data set into the cache memory, wherein the second backup data set is used to indicate the update state of the first backup data in the first backup data set between the target time point and the current time point.
3. The method of claim 2, wherein, The step of writing the first backup data set into the cache memory comprises: Searching for the first backup data in the first backup data set in the cache memory; In the case that the first backup data does not exist in the cache memory, determining the first backup data as cache data and writing it into the cache memory.
4. The method of claim 2, wherein, The step of writing the second backup data set into the cache memory comprises: Determine the first cache data corresponding to the second backup data in the cache memory in the second backup data set; Compare the time information of the second backup data with the time information of the first cache data; In the case that the second backup data is the update data of the first cache data, update the first cache data according to the second backup data.
5. The method according to any one of claims 1 to 4, characterized in that, The step of writing the backup data set into the cache memory corresponding to the cache system node comprises: Determine the access frequency of each backup data in the backup data set; According to the high and low of the access frequency, sort the each backup data to obtain a data write-in sequence; According to the data write-in sequence, write the backup data set into the cache memory.
6. The method of claim 5, wherein, The step of sorting the each backup data according to the high and low of the access frequency to obtain a data write-in sequence comprises: Write the backup data with access frequency not being 0 into a first queue, and write the backup data with access frequency being 0 into a second queue; Sort the backup data in the first queue according to the high and low of the access frequency to obtain the data write-in sequence. The step of writing the backup data set into the cache memory according to the data write-in sequence comprises: Write the backup data in the first queue into the cache memory according to the data write-in sequence; In the case that the backup data in the first queue is written in, write the backup data in the second queue.
7. The method of claim 5, wherein, Before the step of determining the access frequency of each backup data in the backup data set, the method comprises the following steps: In a case where a read-write request for cached data in the cache memory is received, an access number corresponding to the cached data accessed is incremented by one.
8. A data recovery apparatus of a cache system, characterized by comprising: The application relates to a cache system and a cache method. The backup data writing unit is configured to start a new cache system node and write a backup data set into a cache memory corresponding to the cache system node in a case where a cache system node starting condition is met. The data searching unit is configured to receive a read-write request for target data and search for the target data in the cache memory. The data reading unit is configured to read the target data from a database into the cache memory in a case where the target data does not exist in the cache memory, and execute the read-write request on the target data in the cache memory.
9. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instruction is executed by the processor to implement the method in any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method in any one of claims 1 to 7 through the computer program.