Data archiving method, apparatus, computer device, and storage medium
By using a multi-level caching system, data archiving tasks are moved from a high-performance but small-capacity cache to a low-performance but large-capacity cache, and then written to the database in batches in the last-level cache. This solves the problems of server performance waste and data loss caused by periodic archiving, and achieves efficient and reliable data storage.
Patent Information
- Application Number
- CN202210427876.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-22
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-04-22
AI Technical Summary
In existing technologies, periodic archiving schemes lead to wasted server performance and data loss, especially when the server is down, data reliability cannot be guaranteed.
A multi-level caching system is adopted. Data archiving tasks are first stored in the first-level cache, which has high performance but small capacity. When the moving condition is met, the data is moved to the (i+1)th-level cache, which has lower performance but large capacity. The data is then written to the database in batches in the last-level cache and processed according to the execution time of the archiving task.
This reduces the frequency of archiving, alleviates server pressure, and improves the reliability of data archiving, while balancing cost and performance, ensuring timely data storage and read/write speeds.
Smart Images

Figure CN116975103B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of cache technology and database technology, in particular to a data archiving method and device, computer equipment, storage medium and computer program product. BACKGROUND
[0002] Archiving refers to the process of storing data generated during server operation in a database. Data archiving ensures that previous data can be retrieved after server restart or user login, ensuring data integrity.
[0003] Generally, data archiving uses a periodic storage scheme. After server startup, whether the client modifies the data or not, the data is archived every certain period of time. This scheme distributes the archiving pressure at different time points, reducing server pressure. This scheme does not require additional archiving operations in the data modification interface, but uniformly executes archiving logic through a timer at regular intervals. Developers only need to allocate a timer for regular archiving, which is simple to develop and less prone to errors.
[0004] However, the problem with periodic archiving is that even if the data is not modified, it will still be archived, which is unnecessary and wastes server performance. At the same time, since it is periodic archiving, there is a time window. If the server goes down before the archiving opportunity arrives, it will result in data loss, reducing the reliability of archiving. SUMMARY
[0005] Therefore, it is necessary to provide a data archiving method, device, computer equipment, computer readable storage medium and computer program product that can balance cost and improve archiving reliability.
[0006] In a first aspect, the present application provides a data archiving method. The method comprises:
[0007] storing the archiving task of the data into the first-level cache;
[0008] moving the archiving task in the i-level cache to the i+1-level cache when the storage amount of the data in the i-level cache reaches the moving condition; the capacity of the i-level cache is less than that of the i+1-level cache, and the performance level of the i-level cache is higher than that of the i+1-level cache; i is a positive integer;
[0009] batching the archiving task from the last-level cache;
[0010] writing the archiving task into the database according to the archiving execution time of the archiving task.
[0011] In one embodiment, the storing the archiving task of data into the first level cache comprises: storing the archiving task of data into a medium block corresponding to a business process of the archiving task in the first level cache, wherein the first level cache comprises a plurality of medium blocks.
[0012] In another embodiment, each level cache comprises a plurality of medium blocks.
[0013] The moving the archiving task in the i-th level cache to the (i+1)-th level cache comprises: moving the archiving task of each medium block in the i-th level cache to a corresponding medium block in the (i+1)-th level cache; wherein the capacity of each medium block in the i-th level cache is less than the capacity of each medium block in the (i+1)-th level cache, or each medium block in the i-th level cache corresponds to a plurality of medium blocks in the (i+1)-th level cache.
[0014] In another embodiment, the number of medium blocks in each level cache is K, the capacity of each medium block in the same level cache is the same, and the capacity of each medium block in the (i+1)-th level cache is K times the capacity of each medium block in the i-th level cache; the moving the archiving task in the i-th level cache to the (i+1)-th level cache comprises: merging the archiving task of each medium block in the i-th level cache and moving to an idle medium block in the (i+1)-th level cache.
[0015] In another embodiment, the moving condition comprises: each medium block in the i-th level cache is full of the archiving task, or any one of the medium blocks in the i-th level cache is full of the archiving task.
[0016] In another embodiment, the archiving task encapsulates an archiving execution time, and the archiving execution time of different types of data is different.
[0017] The method further comprises: determining a specified cache system according to the archiving execution time, and each cache system comprises a plurality of level caches.
[0018] The storing the archiving task of data into the first level cache comprises: storing the archiving task into a medium block corresponding to a business process of the archiving task in the first level cache of the specified cache system.
[0019] The batch taking out the archiving task from the last level cache comprises: batch taking out the archiving task from the last level cache of each cache system according to a taking-out frequency of each cache system; and the taking-out frequency of each cache system is related to an archiving execution time of the archiving task cached by the cache system.
[0020] In another embodiment, the archiving task encapsulates an archiving execution time, and the archiving execution time of different types of data is different.
[0021] The writing of the archiving task into the database comprises: when the archiving execution time of the archiving task meets, writing the archiving task into the database.
[0022] In a second aspect, the present application provides a data archiving device.
[0023] The cache module is configured to store the archiving task of the data into the first-level cache.
[0024] The moving module is configured to move the archiving task in the i-th level cache to the (i+1)-th level cache when the storage amount of the data in the i-th level cache reaches a moving condition; the capacity of the i-th level cache is less than that of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than that of the (i+1)-th level cache; i is a positive integer.
[0025] The taking-out module is configured to take out the archiving task from the last-level cache in batches.
[0026] The archiving module is configured to write the archiving task into the database according to the archiving execution time of the archiving task.
[0027] In a third aspect, the present application provides a computer device. The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0028] The archiving task of the data is stored into the first-level cache.
[0029] The archiving task in the i-th level cache is moved to the (i+1)-th level cache when the storage amount of the data in the i-th level cache reaches a moving condition; the capacity of the i-th level cache is less than that of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than that of the (i+1)-th level cache; i is a positive integer.
[0030] The archiving task is taken out from the last-level cache in batches.
[0031] The archiving task is written into the database according to the archiving execution time of the archiving task.
[0032] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following steps:
[0033] The archiving task of the data is stored into the first-level cache.
[0034] move the archiving task in the i-th level cache to an (i+1)-th level cache when the storage amount of data in the i-th level cache reaches a moving condition; the capacity of the i-th level cache is less than that of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than that of the (i+1)-th level cache; i is a positive integer;
[0035] batching the archiving task from the last level cache;
[0036] writing the archiving task into a database according to the archiving execution time of the archiving task.
[0037] In a fifth aspect, the present application further provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the following steps:
[0038] storing the archiving task of data into a first level cache;
[0039] move the archiving task in the i-th level cache to an (i+1)-th level cache when the storage amount of data in the i-th level cache reaches a moving condition; the capacity of the i-th level cache is less than that of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than that of the (i+1)-th level cache; i is a positive integer;
[0040] batching the archiving task from the last level cache;
[0041] writing the archiving task into a database according to the archiving execution time of the archiving task.
[0042] The data archiving method, device, computer device, storage medium and computer program product described above, because a multi-level cache system is provided, and when a certain condition is met, data is moved from a storage medium with high performance but small capacity to a storage medium with low performance but high capacity, and then the archiving task is batched from the last level cache and written into a database. That is, the modified data is not immediately written into the database after modification, but is temporarily stored in the multi-level cache system, and by setting the moving condition, the modified data is not immediately stored, thereby reducing the archiving frequency and relieving the server pressure. Through the change of the performance of the multi-layer storage medium, the performance of the first level cache responding to the archiving task of the cache is optimal, and with the increase of the level, the performance of the storage medium decreases and the capacity increases, so that the reading and writing speed is guaranteed, the cost and performance are taken into account, and the reliability of archiving is improved. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 a diagram of an application environment of a data archiving method in an embodiment;
[0044] Figure 2 a schematic diagram of a data cache system in an embodiment;
[0045] Figure 3 Flowchart of a data archiving method in an embodiment;
[0046] Figure 4 Working diagram of a data caching system in an embodiment;
[0047] Figure 5 Working diagram of a data caching system in another embodiment;
[0048] Figure 6 Structural diagram of an archiving task in an embodiment;
[0049] Figure 7 Working flow diagram of a data caching system in an embodiment;
[0050] Figure 8 Working flow diagram of a data caching system in another embodiment
[0051] Figure 9 Structural block diagram of a data archiving device in an embodiment;
[0052] Figure 10 Internal structural diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0053] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0054] The data archiving method provided by the embodiments of the present application can be applied in an application environment as shown in the figure. Figure 1 The terminal 102 communicates with the server 104 through a network. The database 108 can store data required to be processed by the server 104. In order to control data archiving, a caching system 106 is set. The caching system receives archiving tasks of the server, caches and controls the archiving tasks, and then writes them into the database 108. The database is a collection of data stored together in a certain way, shared by multiple users, with as little redundancy as possible, and independent of application programs. Users can perform operations such as adding, updating, and deleting data in the database. The database 108 and the caching system 106 can be integrated on the server 104, or placed on the cloud or other servers.
[0055] The cache system stores the archiving task of data into the first level cache, and when the storage amount of data in the i-th level cache reaches the moving condition, moves the archiving task in the i-th level cache to the (i+1)-th level cache; the capacity of the i-th level cache is less than that of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than that of the (i+1)-th level cache; i is a positive integer; the archiving task is taken out from the last level cache in batches, and written into the database according to the archiving execution time of the archiving task.
[0056] The terminal 102 can be, but is not limited to, various desktop computers, notebook computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The server 104 can be implemented by an independent server or a server cluster composed of multiple servers.
[0057] The cache system includes multiple levels of caches, and the archiving task generated by data modification is first stored in the first level cache. The caches of the cache system have a directional relationship of data movement, and when the storage amount of data in the i-th level cache reaches the moving condition, the archiving task in the i-th level cache is moved to the (i+1)-th level cache. The performance level of the i-th level cache is higher than that of the (i+1)-th level cache, and the capacity of the i-th level cache is less than that of the (i+1)-th level cache.
[0058] That is, from the first level cache to the last level cache of the cache system, the storage medium capacity of the cache is increased in turn, and the performance is reduced in turn. The storage medium refers to the carrier for storing data. The storage medium can be a memory, a floppy disk, an optical disk, a DVD, a hard disk, a flash memory, a U disk, a CF card, an SD card, an MMC card, an SM card, a Memory Stick, an xD card, etc. Different storage media have different characteristics, and the cost is usually related to the read-write bandwidth. The larger the bandwidth, the more expensive the cost. Among them, the specific type of each level of cache can be determined based on the capacity and performance relationship between each level of cache. For example, a cache system includes three levels of caches, the first level cache is a shared memory, the second level cache is a solid state disk, and the third level cache is a mechanical hard disk. From the first level cache to the third level cache, the performance is reduced in turn, and the capacity is increased in turn. It can be understood that in other embodiments, the architecture of the cache system can include more levels, such as four levels of caches, or fewer levels, such as two levels of caches.
[0059] Specifically, the archiving task is first stored into the first-level cache, the first-level cache is used to cache the archiving task in real time during the server running process, and needs to communicate with the server in real time, so the first-level cache needs to have good performance. The first-level cache selects shared memory, because the access speed of shared memory is high, 1MB data reading and writing only needs 3 microseconds, and shared memory has the persistence of storage, even if the server process is down, the data in the shared memory will not be lost, and the data in the shared memory can be obtained after the process is restarted, avoiding data loss. The second-level cache first uses a solid state drive (SSD), the cost of the solid state drive is lower than that of the memory, and the access speed is faster than that of the mechanical hard disk, and 1MB data reading and writing only needs 49 microseconds. The third-level cache selects a mechanical hard disk, the mechanical hard disk has low cost and large space, and the access speed is relatively slow, and 1MB data reading and writing needs 825 microseconds. Through the layer-by-layer change of the storage medium, the low cost of the hardware is ensured, and at the same time the data reading and writing speed is ensured, and the cost and performance are considered.
[0060] It can be understood that in actual application, the number of levels of the cache in the cache system and the type of medium selected by each level of cache can be set as needed, which is not limited here.
[0061] In one embodiment, as shown in Figure 3 , a data processing method is provided, which is applied to the cache system in Figure 1 and Figure 2 for example, and includes the following steps:
[0062] Step 302, storing the archiving task of the data into the first-level cache.
[0063] The cache system is applied to a server, and when a user operates a client to operate data modification, deletion, increase and the like, an archiving task is generated. Taking application to a game scene as an example, when a game player configures a new costume for a character on the client, an archiving task is generated.
[0064] The cache system includes multiple levels of cache, and the first-level cache is used to cache the archiving task in real time during the server running process. Therefore, the first-level cache needs to communicate with the server in real time, which requires the first-level cache to have good performance. Preferably, the first-level cache selects shared memory, because the access speed of shared memory is high, 1MB data reading and writing only needs 3 microseconds, and shared memory has the persistence of storage, even if the server process is down, the data in the shared memory will not be lost, and the data in the shared memory can be obtained after the process is restarted, avoiding data loss.
[0065] Step 304, when the storage amount of data in the i-th level cache reaches the moving condition, the archived task in the i-th level cache is moved to the (i+1)-th level cache; the capacity of the i-th level cache is less than the capacity of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than the performance of the (i+1)-th level cache; i is a positive integer.
[0066] The cache system includes multiple levels of caches, and the storage capacity of each level of cache increases in turn, and the performance of the storage medium decreases in turn. There is a directional relationship between the data movement of each level of cache of the cache system, and when the storage amount of data in the i-th level cache reaches the moving condition, the archived task in the i-th level cache is moved to the (i+1)-th level cache. Wherein, i is a positive integer. The minimum value of i is 1, and the maximum value of i is the number of groups of storage media of the cache system-1. For example, the cache system includes two levels of caches, and when the storage amount in the first level cache reaches the moving condition, the archived task in the first level cache is moved to the second level cache. When a cache system includes three levels of caches, the storage amount in the first level cache reaches the moving condition, and the archived task in the first level cache is moved to the second level cache. When the storage amount in the second level cache reaches the moving condition, the archived task in the second level cache is moved to the third level cache.
[0067] The capacity of the i-th level cache is less than the capacity of the (i+1)-th level cache, and the performance level of the i-th level cache is higher than the performance of the (i+1)-th level cache. The performance is reflected in the read-write speed. The better the performance, the faster the read-write speed. And often the storage medium with better performance has higher cost. In an embodiment, the storage medium is divided into performance levels according to performance. The better the performance, the higher the performance level. For example, the performance level of shared memory is the best, followed by fixed hard disk, and the performance level of mechanical hard disk is lower than that of solid state hard disk.
[0068] Taking a cache system including three levels of caches as an example, the archived task is first stored in the first level cache with high performance but low capacity. When the storage amount of the first level cache reaches the moving condition, the archived task of the first level cache is moved to the second level cache. The performance of the second level cache is lower than that of the first level cache, but the capacity is increased, which can store more archived tasks, but the cost is relatively reduced compared with the first level cache. When the storage amount of the second level cache reaches the moving condition, the archived task of the second level cache is moved to the third level cache. The performance of the third level cache is lower than that of the second level cache, but the capacity is increased, which can store more archived tasks, but the cost is relatively reduced compared with the second level cache.
[0069] The cache system sets multiple levels of cache, directional relationship of data movement between the levels of cache, and performance and capacity of the cache, so that the performance of the first level of cache responding to the archive task of the server is the best and the capacity is the smallest, which can respond to the archive task of the server in a relatively short time. With the increase of the archive task, the archive task is constantly moved to the next group of storage medium with lower cost, so that the reading and writing speed is guaranteed, and the cost and performance are considered.
[0070] The moving condition is a condition related to the storage amount of data in the cache, which can be set according to actual needs. For example, in order to control the archive frequency, the moving condition can be set as full storage of the i-th level of cache, that is, when the i-th level of cache is full, the archive task in the i-th level of cache is moved to the i+1-th level of cache. A storage capacity threshold can also be set, and when the storage capacity threshold is exceeded, the archive task in the i-th level of cache is moved to the i+1-th level of cache.
[0071] It can be understood that the archive task in the i-th level of cache is moved to the i+1-th level of cache, the archive task in the i-th level of cache is deleted, and the storage space of the i-th level of cache is released for storing new archive tasks.
[0072] Step 306, batch taking out multiple tasks from the last level of cache.
[0073] The capacity of the last level of cache is the largest and the cost is the lowest. In order to ensure the efficiency of data archiving, multiple archive tasks can be batch taken out from the last batch of storage medium and written into the database. For example, an archive process can be deployed, and the archive process batch reads archive tasks from the last level of cache. Batch reading can pull N archive tasks, which can save a lot of disk addressing time compared with pulling archive tasks one by one.
[0074] Step 308, writing the archive task into the database according to the archive execution time of the archive task.
[0075] The execution time of the archive task refers to the specified time when the archive task is stored into the database, and the archive execution time of different archive tasks is different. In one way, in response to the data modification operation of the business process, the archive task is created, and the archive execution time of the archive task is determined according to the data type. By setting the archive execution time, the modified data is not immediately archived, and the modified data is encapsulated into an archive task and temporarily cached in the cache system. Each archive task needs to set the archive execution time of the task when it is generated. When the archive execution time comes, the task will be popped out from the cache system and executed for data archiving. The archive execution time can be set by the business needs, for example, the archive execution time of important data can be set to a small value for timely archiving, and the archive execution time of ordinary data can be set to a large value to save server performance.
[0076] Wherein, the storing of the archive task into the cache system and the taking of the archive task from the cache system are parallel, like producer threads and consumer threads. The producer threads are responsible for storing the archive task into the cache system, and the consumer threads are responsible for taking the archive task from the cache system and writing into the database.
[0077] The data archiving method described above, due to the setting of the multi-level cache system, and when certain conditions are met, the data is moved from the storage medium with high performance but small capacity to the storage medium with low performance but high capacity, and then the archive task is taken out in batches from the last level cache and written into the database. That is, the modified data is not immediately written into the database after the data is modified, but is temporarily stored in the multi-level cache system, and by setting the moving condition, the modified data is not immediately stored, reducing the archiving frequency and relieving the server pressure. And through the change of the performance of the multi-layer storage medium, the performance of the first level cache responding to the archive task of the cache system is optimal, and with the increase of the level, the performance of the storage medium decreases and the capacity increases, which guarantees the read-write speed, takes into account the cost and performance, and improves the reliability of the archive.
[0078] A process is a certain independent function program about a certain data set. It is the basic unit of dynamic execution of the operating system, and in the traditional operating system, the process is the basic allocation unit and the basic execution unit. In order to improve the efficiency of data processing, a multi-process or multi-thread architecture is usually used in the server, that is, multiple processes or threads work at the same time, and they all need data archiving. If only one medium block is used in each level of cache, multiple processes or threads will access a medium block at the same time, which will cause a competitive relationship. In order to avoid this competitive relationship, one way is to lock the medium block to ensure that each process or thread uses the medium block in order and in series. But the lock operation will cause the processes to queue each other, affecting the processing speed of the processes. To solve this technical problem, in the embodiment, multiple medium blocks are set for each level of cache, and each business process has its own medium block. When archiving, the business process only accesses the exclusive medium block, without queuing, which can greatly improve the execution speed of the process.
[0079] Specifically, the first level cache of the cache system is set with a plurality of medium blocks, i.e. the first level cache is composed of a plurality of medium blocks. The number of medium blocks can be determined according to the number of business processes, and the data of the medium blocks can be determined, such as one business process corresponding to one medium block, or multiple business processes corresponding to one medium block. The capacities of the medium blocks can be the same or different according to the data modification frequency of the business processes. For example, the medium block corresponding to the business process with high data modification frequency is set to have a larger capacity, and the medium block corresponding to the business process with low data modification frequency is set to have a smaller capacity. The archive task generated by data modification is stored in the medium block corresponding to the business process in the first level cache.
[0080] That is, when the archive task is written into the first level cache, the corresponding relationship between the business process and the medium block is utilized, and the archive task is written into the medium block specified by the business process. By setting the corresponding relationship between the business process and each medium block of the first group, each business process has its own specific medium block, and when the archive task corresponding to the business process is written, the business processes access the exclusive medium block respectively, without queuing, which can greatly improve the execution speed of the process.
[0081] In another embodiment, the corresponding relationship between each medium block of the i-th level cache and each medium block of the i+1-th level cache can also be set, so that each business process has a specified medium block in each level cache, and when the data moves between each level cache, it does not need to queue, which improves the moving efficiency.
[0082] Each level cache is composed of a plurality of medium blocks, and the number of medium blocks of each level cache can be the same or different, but regardless of which setting method is used, the capacity of the i-th level cache is smaller than the capacity of the i+1-th level cache. For example, each level cache can be set to have the same number of medium blocks, and the capacity of each medium block of the i+1-th level cache is greater than the capacity of each medium block of the i-th level cache. At this time, the medium block of the i+1-th level cache can be set to correspond to one medium block of the i+1-th level cache.
[0083] The number of medium blocks of each level cache can also be set to be different, such as the number of medium blocks of the i+1-th level cache being greater than the number of medium blocks of the i-th level cache. At this time, each medium block of the i-th level cache corresponds to a plurality of medium blocks of the i+1-th level cache.
[0084] Specifically, the corresponding relationship between the business process and the medium block of the first storage medium is set, and the corresponding relationship between each medium block of the i-th level cache and each medium block of the i-th level cache is set. The archive task generated by data modification is stored in the medium block corresponding to the business process in the first level cache. For each level cache, when the storage amount of the data in the i-th level cache reaches the moving condition, the archive tasks of each medium block in the i-th level cache are moved to the corresponding medium block in the i+1-th level cache.
[0085] When the archived task is moved from the i-th level cache to the i+1-th level cache, the correspondence between the media blocks of the i-th level cache and the media blocks of the i-th level cache is utilized to move the task of the media blocks of the i-th level cache to the designated media blocks of the i+1-th level cache.
[0086] For example, the cache system shown in FIG. 1 includes three levels of caches, and each level of cache includes three media blocks. The first media block in the first level of cache has a correspondence with the business process A, the second media block has a correspondence with the business process B, and the third media block has a correspondence with the business process C. The first media blocks in each level of cache have a correspondence with each other, the second media blocks in each level of cache have a correspondence with each other, and the third media blocks in each level of cache have a correspondence with each other. Figure 4 Specifically, the archived task of the business process A is stored in the first media block of the first level of cache, the archived task of the business process B is stored in the second media block of the first level of cache, and the archived task of the business process C is stored in the third media block of the first level of cache. When the storage amount of the data in the first level of cache reaches the moving condition, the archived task of the first media block in the first level of cache is moved to the first media block of the second level of cache, the archived task of the second media block in the first level of cache is moved to the second media block of the second level of cache, and the archived task of the third media block in the first level of cache is moved to the third media block of the second level of cache. When the storage amount of the data in the second level of cache reaches the moving condition, the archived task of the first media block in the second level of cache is moved to the first media block of the third level of cache, the archived task of the second media block in the second level of cache is moved to the second media block of the third level of cache, and the archived task of the third media block in the second level of cache is moved to the third media block of the third level of cache.
[0087] By setting the correspondence between the business processes and the media blocks of the first group and the correspondence between the media blocks of the levels of caches, each process has its own specific media block, and each process accesses the exclusive media block without queuing, which can greatly improve the execution speed of the process.
[0088] In another embodiment, the number of media blocks in each level of cache is K, the capacity of each media block in the same level of cache is the same, and the capacity of each media block in the i+1-th level of cache is K times the capacity of each media block in the i-th level of cache.
[0089]
[0090] Specifically, each level of cache contains K media blocks, and the media blocks are used to cache the archive tasks described above, and the capacity of the media blocks in the same level of cache is the same. The capacity of each media block in the i+1 level of cache is K times the capacity of each media block in the i level of cache. Wherein the capacity of each media block in the 1st level of cache is M, the capacity of each media block in the 2nd level of cache is K*M, the capacity of each media block in the 2nd level of cache is (K^2)*M, and so on, the capacity of each media block in the Gth level of cache is (K^(G-1))*M.
[0091] As shown in Figure 5 , k=3, that is, three media blocks are included in each level of cache. By setting the number of media blocks in each level of cache to be the same, and the capacity of each media block in the i+1 level of cache is K times the capacity of each media block in the i level of cache, when moving the archive tasks of each media block in the i level of cache to the i+1 level of cache, if the moving condition is that the i level of cache is full, then at each time of moving, the archive tasks of each media block in the i level of cache are merged, and each media block in the i level of cache can be moved into the idle media block in the i+1 level of cache, without splitting the archive tasks of each media block in the i level of cache.
[0092] In this embodiment, by setting the number of media blocks in each level of cache to be the same, and the capacity of each media block in the i+1 level of cache is K times the capacity of each media block in the i level of cache, so that after moving, all the archive tasks in the previous level of cache can be merged into one media block in the next level of cache without splitting, improving the moving efficiency.
[0093] As for the 1st level of cache, when all the media blocks in the 1st level of cache are full of archive tasks, all the media blocks in the group are merged and stored in an idle media block in the 2nd level of cache, and then the space of the 1st level of cache is released for storing new archive tasks. Through the layer-by-layer merging between media groups, the size of the space occupied by the shared memory is limited.
[0094] It can be understood that if the capacity size relationship between the media blocks in each level of cache is not set, when migrating, the capacity size of the media block can be first judged. If the capacity of the media block can accommodate the archive tasks of the corresponding media block in the i level of cache, it can be directly moved. If it cannot be accommodated, the archive tasks of the media block in the i level of cache need to be split before moving and stored in multiple media blocks in the i+1 level of cache, or only the archive tasks of the corresponding size in the media block of the i level of cache are moved according to the capacity size of the media block.
[0095] In another embodiment, the moving condition includes that each media block in the i level of cache is full of archive tasks, or any one media block in the i level of cache is full of archive tasks.
[0096] Specifically, when all the media blocks in the i-th level cache are full of archive tasks, the archive tasks of the media blocks in the i-th level cache are merged and moved to the (i+1)-th level cache. The archive tasks of the media blocks in the i-th level cache can also be merged and moved to the (i+1)-th level cache when any one of the media blocks in the i-th level cache is full of archive tasks. Compared with the moving mode that the archive tasks of the media blocks in the i-th level cache are moved when any one of the media blocks is full of archive tasks, the moving mode that the archive tasks of the media blocks in the i-th level cache are moved when all the media blocks are full of archive tasks can move at a slower speed and reduce the archive frequency.
[0097] In another embodiment, the archive task also encapsulates an archive execution time, and the archive execution times of different types of data are different. The archive execution time refers to a specified time for storing the archive task to the database, and the archive execution times of different archive tasks are different. The structure of an archive task is shown in Figure 6 The archive task includes an archive task identifier, an archive execution time, and archive data. The archive task identifier is a unique identifier of the archive task, denoted as DataID. After the data is modified, the modified data is not immediately archived, but is encapsulated into an archive task and temporarily buffered in the cache system. Each archive task needs to set the archive execution time saveTime when generated. When the archive execution time arrives, the task is popped out from the cache system and performs data archiving. The archive execution time can be set by the business needs, for example, the archive execution time of important data can be set to a small value to archive in time, and the archive execution time of ordinary data can be set to a large value to save server performance.
[0098] Specifically, the archive execution time is set in advance according to each data type in the business scenario. When the data modification generates an archive task, the archive execution time of the archive task is determined according to the data type. The length of the archive execution time determines the timeliness of the archiving. The archive execution time can be determined according to the importance of the data type. For example, data related to property and sensitive time can be set to a shorter archive execution time so that the modified data can be stored in time. Data related to player service replacement and equipment replacement can be set to a longer archive execution time to avoid frequent storage causing server pressure.
[0099] The writing of the archive task into the database includes: when the archive execution time of the archive task is met, the archive task is written into the database.
[0100] Specifically, an archive process SaveSvr archive process needs to read the archive tasks in the last level cache. Since the subsequent cache is stored in a hard disk, the data reading speed is slow, and frequent reading of archive tasks will consume a lot of hard disk performance. A memory can be allocated in the archive process, which is used to batch pull the archive tasks in the medium group. The archive tasks will exist temporarily in the memory, and one hard disk reading will pull N archive tasks, which can save a lot of disk addressing time compared with pulling the archive tasks one by one.
[0101] As shown in Figure 7 N archive tasks are batched from the last level cache and placed in the memory. According to the archive execution time in the archive task, it is judged whether the archive execution time has arrived. If the archive execution time has arrived, the data is sent to the database, and if it has not arrived, it does not need to be processed. The archive process receives the successful archive packet from the database, which includes the data identifier. The archive process deletes the archive task from the memory and the last level cache group according to the data identifier.
[0102] This method does not consider the storage time when taking out the archive task from the cache system. By writing the archive execution time, the archive task is written according to the archive execution time, so as to realize writing into the database according to the archive time.
[0103] Similarly, the archive tasks can also be batched from the last level cache according to the archive execution time, that is, the archive tasks are batched from the last level cache according to the archive execution time, so as to realize writing into the database according to the archive time.
[0104] In another embodiment, the archive task encapsulates the archive execution time, and the archive execution time of different types of data is different.
[0105] The data archiving method further includes determining a specified cache system according to the archive execution time, and each cache system includes multiple levels of cache. That is, the server has multiple cache systems, and each cache system has multiple levels of cache.
[0106] The archive task of the data is stored in the first level cache, including: storing the archive task in the first level cache of the specified cache system corresponding to the business process of the archive task.
[0107] Batching archive tasks from the last level cache includes: respectively batch pulling archive tasks from the last level cache of each cache system according to the pulling frequency of each cache system; and the pulling frequency of each cache system is related to the archive execution time of the archive task cached by the cache system.
[0108] The archiving task can be created in response to a data modification operation of a business process, and the archiving execution time of the archiving task is determined according to the data type. By setting the archiving execution time, the data is not archived immediately after being modified, and the modified data is encapsulated into an archiving task and temporarily cached in the cache system. The archiving execution time can be set by the business needs, for example, the archiving execution time of important data can be set to a small value for timely archiving, and the archiving execution time of ordinary data can be set to a large value to save server performance.
[0109] The range of archiving execution time for distinguishing the objects stored in the cache systems is set, and the range of archiving execution time of each cache system is different, so that the archiving tasks in different archiving execution time ranges are stored in different cache systems. This makes the archiving tasks of each cache system have similar archiving execution time.
[0110] Based on this, when setting the taking-out frequency of each cache system, the archiving execution time of the archiving task of each cache system can be considered. For example, for the cache system used to cache the archiving task with a long archiving execution time, a lower taking-out frequency can be set, and for the cache system used to cache the archiving task with a short archiving execution time, a higher taking-out frequency can be set, so that different caches can be operated by setting different taking-out frequencies.
[0111] As shown in Figure 8 , a plurality of cache systems are set, and the archiving execution time of each cache system is different. When the server receives the archiving task, the archiving execution time is determined according to the data type. There are multiple cache systems, and different archiving execution times are set. For example, two cache systems are set, which correspond to different archiving execution time intervals. For example, the archiving execution time frequency of the first cache system is low, and the archiving execution time frequency of the second cache system is high. According to the different archiving execution times, the archiving tasks are stored in different cache systems. Since the cache systems are divided according to the archiving time, the archiving tasks written into the same cache system have similar execution time, and the storage process can operate the cache systems at different frequencies, considering the different needs of the archiving tasks.
[0112] The structure of a cache system is as shown in Figure 7As shown, three levels of caches are included, which are first level cache, second level cache and third level cache. The first level cache adopts shared memory, which is a large capacity memory that can be accessed by different central processing units (CPUs) in a multi-processor computer system. The second level cache adopts solid state disk, which is a hard disk made of solid state electronic storage chip array. The third level cache adopts mechanical hard disk, which is a traditional ordinary hard disk, mainly composed of: disk, head, disk shaft and control motor, head controller, data converter, interface, cache and other parts. The head can move along the radius of the disk, and combined with the high-speed rotation of the disk per minute, the head can be positioned at the specified position of the disk for data read and write operation.
[0113] Through the multi-level heap structure merging mechanism, the shared memory usage rate and the disk performance are considered, the reliable archiving of server data is realized, the server pressure problem caused by frequent archiving in the prior art and the data loss problem caused by regular archiving are solved, and the hardware cost, machine performance and logical reliability are considered.
[0114] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps.
[0115] Based on the same inventive concept, the embodiments of the present application also provide a data archiving device for implementing the above-mentioned data archiving method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more data archiving device embodiments provided below can refer to the limitations of the data archiving method in the above text, which will not be repeated here.
[0116] In one embodiment, as shown in Figure 9 A data archiving device is provided, comprising:
[0117] The cache module 902 is configured to store the archiving task of the data into the first level cache.
[0118] The moving module 904 is configured to move the archived task in the i-th level cache to an (i+1)-th level cache when the storage amount of the data in the i-th level cache reaches a moving condition; the capacity of the i-th level cache is less than that of the (i+1)-th level cache, the performance of the i-th level cache is higher than that of the (i+1)-th level cache; and i is a positive integer.
[0119] The taking-out module 906 is configured to take out the archived task in batches from the last level cache.
[0120] The archiving device 908 is configured to write the archived task into a database according to the archiving execution time of the archived task.
[0121] The data archiving device has a multi-level cache system, and when a certain condition is met, the data is moved from a storage medium with high performance but small capacity to a storage medium with low performance but large capacity, the archived task is taken out in batches from the last level cache, and is written into a database. That is, the modified data is not immediately written into the database after the data is modified, but is temporarily stored in the multi-level cache system, and the data is not immediately stored after the data is modified by setting the moving condition, so as to reduce the archiving frequency and alleviate the server pressure. Through the change of the performance of the multi-layer storage medium, the performance of the first level cache responding to the archiving task of the cache is optimal, and with the increase of the level, the performance of the storage medium decreases and the capacity increases, so that the cost and performance are considered while the read-write speed is ensured, and the reliability of archiving is improved.
[0122] In another embodiment, the cache module stores the archived task of the data into a medium block corresponding to a business process of the archived task in the first level cache, wherein the first level cache includes a plurality of medium blocks.
[0123] In another embodiment, each level cache includes a plurality of media, and the moving module is configured to move the archived task of each medium block in the i-th level cache to a corresponding medium block in the (i+1)-th level cache; wherein the capacity of each medium block in the i-th level cache is less than that of each medium block in the (i+1)-th level cache, or each medium block in the i-th level cache corresponds to a plurality of medium blocks in the (i+1)-th level cache.
[0124] In another embodiment, the number of medium blocks in each level cache is K, the capacity of each medium block in the same level cache is the same, and the capacity of each medium block in the (i+1)-th level cache is K times the capacity of each medium block in the i-th level cache; the moving module combines the archived tasks of each medium block in the i-th level cache and moves them to the idle medium blocks in the (i+1)-th level cache.
[0125] In another embodiment, the moving condition comprises: each medium block in the i-th level cache is full of the archive task, or any one medium block in the i-th level cache is full of the archive task.
[0126] In another embodiment, the archive task encapsulates an archive execution time, and the archive execution time is different for different types of data.
[0127] The data archiving apparatus further comprises an assigning module configured to determine a designated cache system according to the archive execution time, and each cache system comprises a plurality of levels of caches.
[0128] The data archiving apparatus further comprises a caching module configured to store the archive task in a medium block corresponding to a service process of the archive task in a first level cache of the designated cache system.
[0129] The data archiving apparatus further comprises a retrieving module configured to retrieve the archive task from a last level cache of each cache system in batches according to a retrieving frequency of the cache system, and the retrieving frequency of each cache system is related to an archive execution time of the archive task cached in the cache system.
[0130] Each module in the data archiving apparatus can be implemented by software, hardware, or a combination thereof, in whole or in part. Each module can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in a computer device in software form, so as to be called and executed by a processor to perform operations corresponding to each module.
[0131] In one embodiment, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in Figure 10 The computer device comprises a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to archive a task. The input / output interface of the computer device is configured to exchange information between the processor and an external device. The communication interface of the computer device is configured to communicate with a terminal outside through a network connection. The computer program is executed by the processor to implement a data archiving method.
[0132] Those skilled in the art can understand that, Figure 10The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0133] In one embodiment, a computer device is provided, comprising a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program:
[0134] storing the archiving task of the data into the first-level cache;
[0135] moving the archiving task in the i-level cache to the i+1-level cache when the storage amount of the data in the i-level cache reaches a moving condition; the capacity of the i-level cache is less than the capacity of the i+1-level cache, the performance level of the i-level cache is higher than the performance level of the i+1-level cache; i is a positive integer;
[0136] batching the archiving task from the last-level cache;
[0137] writing the archiving task into the database according to the archiving execution time of the archiving task.
[0138] In one of the embodiments, the storing the archiving task of the data into the first-level cache comprises: storing the archiving task of the data into the medium block corresponding to the business process of the archiving task in the first-level cache, wherein the first-level cache comprises a plurality of medium blocks.
[0139] In another embodiment, each level of cache comprises a plurality of medium blocks;
[0140] The moving the archiving task in the i-level cache to the i+1-level cache comprises: moving the archiving task of each medium block in the i-level cache to the corresponding medium block in the i+1-level cache; wherein the capacity of each medium block in the i-level cache is less than the capacity of each medium block in the i+1-level cache, or each medium block in the i-level cache corresponds to a plurality of medium blocks in the i+1-level cache.
[0141] In another embodiment, the number of medium blocks in each level of cache is K, the capacity of each medium block in the same level of cache is the same, and the capacity of each medium block in the i+1-level cache is K times the capacity of each medium block in the i-level cache; the moving the archiving task in the i-level cache to the i+1-level cache comprises: merging the archiving task of each medium block in the i-level cache and moving to the idle medium block in the i+1-level cache.
[0142] In another embodiment, the moving condition comprises: each medium block in the i-th level cache is full of the archive task, or any one medium block in the i-th level cache is full of the archive task.
[0143] In another embodiment, the archive task encapsulates an archive execution time, and archive execution times of different types of data are different.
[0144] The method further comprises: determining a designated cache system according to the archive execution time, and each cache system comprises a plurality of levels of caches.
[0145] The storing of the archive task of the data into the first level cache comprises: storing the archive task into a medium block corresponding to a business process of the archive task in the first level cache of the designated cache system.
[0146] The batch taking of the archive task from the last level cache comprises: batch taking the archive task from the last level cache of each cache system according to a taking frequency of the cache system; and the taking frequency of each cache system is related to an archive execution time of the archive task cached by the cache system.
[0147] In another embodiment, the archive task encapsulates an archive execution time, and archive execution times of different types of data are different.
[0148] The writing of the archive task into the database comprises: when the archive execution time of the archive task is satisfied, writing the archive task into the database.
[0149] In one embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following steps:
[0150] The storing of the archive task of the data into the first level cache;
[0151] When the storage amount of the data in the i-th level cache reaches a moving condition, moving the archive task in the i-th level cache to an (i+1)-th level cache; the capacity of the i-th level cache is smaller than that of the (i+1)-th level cache, the performance level of the i-th level cache is higher than that of the (i+1)-th level cache; and i is a positive integer.
[0152] The batch taking of the archive task from the last level cache;
[0153] The writing of the archive task into the database according to the archive execution time of the archive task.
[0154] In one embodiment, the storing the archiving task of data into the first level cache comprises: storing the archiving task of data into a medium block corresponding to a business process of the archiving task in the first level cache, wherein the first level cache comprises a plurality of medium blocks.
[0155] In another embodiment, each level cache comprises a plurality of medium blocks.
[0156] The moving the archiving task in the i-th level cache to the (i+1)-th level cache comprises: moving the archiving task of each medium block in the i-th level cache to a corresponding medium block in the (i+1)-th level cache; wherein the capacity of each medium block in the i-th level cache is less than the capacity of each medium block in the (i+1)-th level cache, or each medium block in the i-th level cache corresponds to a plurality of medium blocks in the (i+1)-th level cache.
[0157] In another embodiment, the number of medium blocks in each level cache is K, the capacity of each medium block in the same level cache is the same, and the capacity of each medium block in the (i+1)-th level cache is K times the capacity of each medium block in the i-th level cache; the moving the archiving task in the i-th level cache to the (i+1)-th level cache comprises: merging the archiving task of each medium block in the i-th level cache and moving to an idle medium block in the (i+1)-th level cache.
[0158] In another embodiment, the moving condition comprises: each medium block in the i-th level cache is full of the archiving task, or any one of the medium blocks in the i-th level cache is full of the archiving task.
[0159] In another embodiment, the archiving task encapsulates an archiving execution time, and the archiving execution time of different types of data is different.
[0160] The method further comprises: determining a specified cache system according to the archiving execution time, and each cache system comprises a plurality of levels of caches.
[0161] The storing the archiving task of data into the first level cache comprises: storing the archiving task into a medium block corresponding to a business process of the archiving task in the first level cache of the specified cache system.
[0162] The batch taking out the archiving task from the last level cache comprises: batch taking out the archiving task from the last level cache of each cache system according to a taking-out frequency of each cache system; and the taking-out frequency of each cache system is related to an archiving execution time of the archiving task cached by the cache system.
[0163] In another embodiment, the archiving task encapsulates an archiving execution time, and the archiving execution time of different types of data is different.
[0164] writing the archive task into a database comprises: writing the archive task into the database when an archive execution time of the archive task is satisfied.
[0165] In one embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the following steps:
[0166] storing archive tasks of data into a first level cache;
[0167] moving archive tasks in an i-th level cache to an (i+1)-th level cache when a storage amount of data in the i-th level cache reaches a moving condition; the i-th level cache has a smaller capacity than the (i+1)-th level cache, and the i-th level cache has a higher performance than the (i+1)-th level cache; i is a positive integer;
[0168] batching archive tasks from a last level cache;
[0169] writing the archive tasks into a database according to archive execution times of the archive tasks.
[0170] In one of the embodiments, the storing of the archive tasks of data into the first level cache comprises storing the archive tasks of data into media blocks corresponding to business processes of the archive tasks in the first level cache, wherein the first level cache comprises a plurality of media blocks.
[0171] In another embodiment, each level cache comprises a plurality of media blocks.
[0172] The moving of the archive tasks in the i-th level cache to the (i+1)-th level cache comprises moving the archive tasks of each media block in the i-th level cache to corresponding media blocks in the (i+1)-th level cache, wherein each media block in the i-th level cache has a smaller capacity than each media block in the (i+1)-th level cache, or each media block in the i-th level cache corresponds to a plurality of media blocks in the (i+1)-th level cache.
[0173] In another embodiment, each level cache comprises K media blocks, each media block in a same level cache has the same capacity, and each media block in the (i+1)-th level cache has a capacity K times of each media block in the i-th level cache; the moving of the archive tasks in the i-th level cache to the (i+1)-th level cache comprises merging the archive tasks of each media block in the i-th level cache and moving the archive tasks to an idle media block in the (i+1)-th level cache.
[0174] In another embodiment, the moving condition comprises that each media block in the i-th level cache is full of the archive tasks, or any one media block in the i-th level cache is full of the archive tasks.
[0175] In another embodiment, the archive task encapsulates an archive execution time, and archive execution times of different types of data are different;
[0176] The method further comprises determining a specified cache system according to the archive execution time, each cache system comprising a plurality of levels of cache;
[0177] The storing of the archive task of the data into the first level of cache comprises storing the archive task into a medium block corresponding to a service process of the archive task in the first level of cache of the specified cache system.
[0178] The batch retrieval of the archive task from the last level of cache comprises batch retrieval of the archive task from the last level of cache of each cache system according to a retrieval frequency of each cache system, and the retrieval frequency of each cache system is related to an archive execution time of the archive task cached by the cache system.
[0179] In another embodiment, the archive task encapsulates an archive execution time, and archive execution times of different types of data are different;
[0180] The writing of the archive task into the database comprises writing the archive task into the database when the archive execution time of the archive task meets.
[0181] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0182] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0183] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0184] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method of archiving data, characterized by, The method comprises: storing an archiving task of data into a medium block corresponding to a business process of the archiving task in a first-level cache; each level of cache comprises a plurality of medium blocks; different business processes correspond to different medium blocks; the archiving task encapsulates an archiving execution time; when the storage amount of data in an i-level cache reaches a moving condition, merging the archiving tasks of each medium block in the i-level cache and moving to an idle medium block in an (i+1)-level cache to delete the archiving tasks in the i-level cache; the capacity of the i-level cache is smaller than that of the (i+1)-level cache, and the performance level of the i-level cache is higher than that of the (i+1)-level cache; i is a positive integer; batching out archiving tasks from a last-level cache by an archiving process and temporarily storing the archiving tasks in a memory of the archiving process; when the archiving execution time of the archiving tasks in the memory has arrived, writing the archiving tasks into a database and then deleting the archiving tasks from the memory and the last-level cache.
2. The method of claim 1, wherein, The capacity of each medium block in the i-level cache is smaller than that of each medium block in the (i+1)-level cache, or each medium block in the i-level cache corresponds to a plurality of medium blocks in the (i+1)-level cache.
3. The method of claim 1, wherein, The number of medium blocks in each level of cache is K, the capacity of each medium block in the same level of cache is the same, and the capacity of each medium block in the (i+1)-level cache is K times the capacity of each medium block in the i-level cache.
4. The method according to any one of claims 1 to 3, characterized in that, The moving condition comprises that each medium block in the i-level cache is full of the archiving tasks, or any one of the medium blocks in the i-level cache is full of the archiving tasks.
5. The method of claim 1, wherein, The archiving execution time of different types of data is different. The method further comprises determining a specified cache system according to the archiving execution time, and each cache system comprises a plurality of levels of cache. The step of storing the archiving task of data into a medium block corresponding to a business process of the archiving task in a first-level cache comprises: The step of batching out archiving tasks from a last-level cache by an archiving process comprises: batching out archiving tasks from a last-level cache of each cache system by an archiving process according to the taking-out frequency of each cache system; the taking-out frequency of each cache system is related to the archiving execution time of the archiving tasks cached by the cache system.
6. A data archiving apparatus characterized by comprising: The apparatus comprises: a cache module configured to store an archiving task of data into a medium block corresponding to a business process of the archiving task in a first-level cache; each level of cache comprises a plurality of medium blocks; different business processes correspond to different medium blocks; the archiving task encapsulates an archiving execution time; a moving module configured to, when the storage amount of data in an i-level cache reaches a moving condition, merge the archiving tasks of each medium block in the i-level cache and move to an idle medium block in an (i+1)-level cache to delete the archiving tasks in the i-level cache; the capacity of the i-level cache is smaller than that of the (i+1)-level cache, and the performance level of the i-level cache is higher than that of the (i+1)-level cache; i is a positive integer. a taking-out module, configured to take out the archiving tasks from the last-level cache in batches through the archiving processes and temporarily store the archiving tasks in a piece of memory of the archiving processes; an archiving module, configured to delete the archiving tasks from the memory and the last-level cache after writing the archiving tasks into a database when archiving execution time of the archiving tasks in the memory has arrived.
7. The data archiving apparatus of claim 6, wherein The capacity of each medium block of the i-th level cache is less than the capacity of each medium block of the i+1-th level cache, or each medium block of the i-th level cache corresponds to multiple medium blocks of the i+1-th level cache.
8. The data archiving apparatus of claim 6, wherein, The number of medium blocks in each level cache is K, the capacity of each medium block in the same level cache is the same, and the capacity of each medium block in the i+1-th level cache is K times the capacity of each medium block in the i-th level cache.
9. The data archiving apparatus of any one of claims 6 to 8, wherein, The moving condition includes that each medium block in the i-th level cache is full of the archiving tasks or any medium block in the i-th level cache is full of the archiving tasks.
10. The data archiving apparatus of claim 6, wherein, The archiving execution time of different types of data is different. The data archiving device further comprises an assigning module, configured to determine a designated cache system according to the archiving execution time, and each cache system comprises multiple level caches. The cache module is configured to store the archiving tasks in the first-level cache of the designated cache system and in the medium block corresponding to the service process of the archiving tasks. The taking-out module is configured to take out the archiving tasks from the last-level cache of each cache system in batches through the archiving processes according to the taking-out frequency of each cache system, and the taking-out frequency of each cache system is related to the archiving execution time of the archiving tasks cached by the cache system. 11.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-10. The processor executes the computer program to implement the method in any one of claims 1 to 5.
12. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method in any one of claims 1 to 5.
13. A computer program product comprising computer instructions, characterized in that, The computer program is executed by the processor to implement the method in any one of claims 1 to 5.
Citation Information
Patent Citations
Bus communication method and system
CN105677592A