Expired key deletion method, device, equipment and storage medium

By obtaining and sorting preset key link lists, instant deletion and efficiency processing of expired keys are achieved, and the problem of low system running rate caused by expired key occupies system memory in the existing technology is solved, and the server's operation efficiency and resources are improved Utilization.

CN115033564BInactive Publication Date: 2024-11-22CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210680761.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-16
Publication Date
2024-11-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, expired keys cannot be deleted immediately, resulting in the problem of low system operation speed.

Method used

By obtaining the preset key link list, detecting and sorting the expiration time of the system key, immediately delete the keys in the expired state, and limiting the number of key deletion instructions within the set time period to avoid resource overload.

Benefits of technology

It improves the efficiency of deletion of expired keys, releases server storage pressure, improves the server's running rate, and reduces the burden on resources of expired key deletion processing when high loads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033564B_ABST
    Figure CN115033564B_ABST
Patent Text Reader

Abstract

The present invention discloses an expired key deletion method, device, equipment and storage medium. The method starts a key access process when a preset key chain list is not empty, and when the key access process determines that the first key is in an expired state according to the expiration time, executes a first key deletion instruction to delete the first key, and accumulates the total key deletion amount by one; obtains a first comparison time and a preset time interval, and determines whether the first time interval is greater than the preset time interval; when the first time interval is less than the preset time interval, obtains a preset deletion threshold, and compares the total key deletion amount with the preset deletion threshold; when the total key deletion amount is greater than or equal to the preset deletion threshold, switches the key access process to a pause state to stop deleting system keys. The present invention improves the efficiency of deleting system keys in an expired state, releases the storage pressure of a server, and improves the running speed of the server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data cache technology, and in particular to an expired key deletion method, device, equipment and storage medium. Background Art

[0002] Redis (Remote Dictionary Server) is a high-performance non-relational Key-Value database that can act as a cache container in the system to improve system response time. However, if the expiration time of the key is not set, the key will occupy the system memory for a long time.

[0003] In the prior art, expired keys are generally deleted by lazy deletion or periodic deletion. Lazy deletion is to check the key for expiration when the key reaches the specified expiration time, and only perform the deletion operation if it is expired. Periodic deletion is to periodically poll to check whether there is an expired key in the system, and only perform the deletion operation if it exists. In other words, the lazy deletion or periodic deletion methods will not delete expired keys immediately, resulting in expired keys occupying system memory space, thereby causing the system to run at a lower speed. Summary of the invention

[0004] The embodiments of the present invention provide a method, device, equipment and storage medium for deleting expired keys, so as to solve the problem in the prior art that expired keys cannot be deleted immediately, resulting in a low system movement rate.

[0005] A method for deleting an expired key, comprising:

[0006] Obtaining a preset key chain table, and detecting whether the preset key chain table is empty; the preset key chain table is used to store key nodes of system keys; one of the key nodes includes a key pointer and an expiration time corresponding to the system key;

[0007] When the preset key chain list is not empty, start a key access process to determine whether a first key is in an expired state according to the expiration time through the key access process; the first key refers to a system key corresponding to the key node ranked first in the preset key chain list;

[0008] When the first key is in an expired state, executing a first key deletion instruction to delete the first key, and accumulating the total number of key deletions by one; the first key deletion instruction is generated according to the key pointer corresponding to the first key;

[0009] Obtain a first comparison time and a preset time interval, and determine whether the first time interval is greater than the preset time interval; the first time interval refers to the interval between the first comparison time and the current detection time; the current detection time is the time when the key access process is started;

[0010] When the first time interval is less than the preset time interval, obtaining a preset deletion threshold, and comparing the total key deletion amount with the preset deletion threshold;

[0011] When the total amount of key deletions is greater than or equal to the preset deletion threshold, the key access process is switched to a pause state to stop deleting the system key.

[0012] An expired key deletion device, comprising:

[0013] A linked list acquisition module, used to acquire a preset key linked list and detect whether the preset key linked list is empty; the preset key linked list is used to store key nodes of system keys; one of the key nodes includes a key pointer and an expiration time corresponding to the system key;

[0014] A first detection module, configured to start a key access process when the preset key chain list is not empty, so as to determine whether a first key is in an expired state according to the expiration time through the key access process; the first key refers to a system key corresponding to the key node ranked first in the preset key chain list;

[0015] A first deletion module, configured to, when the first key is in an expired state, execute a first key deletion instruction to delete the first key, and accumulate a total key deletion amount by one; the first key deletion instruction is generated according to a key pointer corresponding to the first key;

[0016] A first comparison module, used to obtain a first comparison time and a preset time interval, and determine whether the first time interval is greater than the preset time interval; the first time interval refers to the interval between the first comparison time and the current detection time; the current detection time is the time when the key access process is started;

[0017] A first comparison module, configured to obtain a preset deletion threshold when the first time interval is less than the preset time interval, and compare the total key deletion amount with the preset deletion threshold;

[0018] The first pause module is used to switch the key access process to a pause state to stop deleting the system key when the total key deletion amount is greater than or equal to the preset deletion threshold.

[0019] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned expired key deletion method when executing the computer program.

[0020] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for deleting expired keys is implemented.

[0021] The above-mentioned expired key deletion method, device, equipment and storage medium, the method sorts the key nodes corresponding to each system key in the order of expiration time by setting a preset key chain list. In this way, the system keys in an expired state can be deleted in an orderly and accurate manner. When it is determined that the system key is in an expired state, the system key is deleted immediately, which improves the efficiency of deleting the system keys in an expired state, releases the storage pressure of the server, and improves the operation rate of the server. After the system keys in an expired state are deleted, the number of system keys in an expired state that can execute the key deletion command within the currently set time period is limited by the preset deletion threshold. In this way, when the server is in a high system utilization rate, the resource burden brought to the server by the expired key deletion process is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0023] Figure 1 Schematic diagram of an application environment of an expired key deletion method in one embodiment of the present invention;

[0024] Figure 2 is a flow chart of a method for deleting expired keys in one embodiment of the present invention;

[0025] Figure 3 is a principle block diagram of an expired key deletion device in one embodiment of the present invention;

[0026] Figure 4 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0028] The expired key deletion method provided in the embodiment of the present invention can be applied as follows: Figure 1 Specifically, the expired key deletion method is applied in an expired key deletion system, and the expired key deletion system includes: Figure 1The client and server shown in the figure communicate with each other through the network, which is used to solve the problem in the prior art that expired keys cannot be deleted immediately, resulting in a low system movement rate. Among them, the client, also known as the user end, refers to a program corresponding to the server that provides local services to customers. The client can be installed on but not limited to various personal computers, laptops, smart phones, tablets and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers. Among them, the server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.

[0029] In one embodiment, if Figure 2 As shown, a method for deleting expired keys is provided, and the method is applied in Figure 1 The server in the example is used as an example to illustrate the process, including the following steps:

[0030] S10: Obtain a preset key chain table, and detect whether the preset key chain table is empty; the preset key chain table is used to store key nodes of system keys; one of the key nodes includes a key pointer and an expiration time corresponding to the system key.

[0031] It can be understood that the preset key linked list is used to store the key nodes corresponding to the system keys in the server, and in the preset key linked list, each key node is sorted in the order of the expiration time of the system key. That is, the closer the expiration time is to the system time of the server, the higher the key node corresponding to it is sorted in the preset key linked list; the farther the expiration time is from the system time of the server, the lower the key node corresponding to it is sorted in the preset key linked list. Furthermore, a key node stores the key pointer and expiration time corresponding to the system key. Among them, the key pointer is used to indicate the storage location of the system key in the server. The expiration time is used to indicate the time point when the system key is converted to an expired key.

[0032] Specifically, after obtaining the preset key chain list, the key nodes in the preset key chain list can be traversed to see if they store the key pointer and expiration time corresponding to the system key. If all key nodes do not store the key pointer and expiration time corresponding to the system key, it indicates that the preset key chain list is empty. The preset key chain list may be empty because all the system keys corresponding to the key nodes stored in the preset key chain list have been deleted (for example, the system keys corresponding to the key nodes stored in the preset key chain list are all expired keys and have been deleted from the server system).

[0033] S20: When the preset key chain list is not empty, start a key access process to determine whether a first key is in an expired state according to the expiration time through the key access process; the first key refers to the system key corresponding to the first key node in the preset key chain list.

[0034] It can be understood that the key access process is used to access the expiration time of the system key stored in the key node in the preset key chain list. The expiration status indicates that the time corresponding to the start of the key access process has exceeded the expiration time of the first key. Among them, the above description points out that the key nodes in the preset key chain list are sorted in the order of the expiration time of each system key. Therefore, the first key is the system key corresponding to the key node ranked first in the preset key chain list. That is, among the system keys corresponding to all key nodes in the preset key chain list, the expiration time corresponding to the first key is earlier than the expiration time corresponding to other system keys.

[0035] Specifically, after detecting whether the preset key chain list is empty, when the preset key chain list is not empty, a key access process is established and started to access the expiration time corresponding to the first ranked system key in the preset key chain list through the key access process. The current detection time corresponding to the start of the key access process is compared with the expiration time corresponding to the first key to determine whether the current detection time exceeds the expiration time corresponding to the first key. When the current detection time exceeds the expiration time corresponding to the first key, it is determined that the first key is in an expired state; when the current detection time exceeds the expiration time corresponding to the first key, it is determined that the first key is not in an expired state.

[0036] S30: When the first key is in an expired state, execute a first key deletion instruction to delete the first key, and add a total number of key deletions to one; the first key deletion instruction is generated according to a key pointer corresponding to the first key.

[0037] It can be understood that the total key deletion amount refers to the total number of system keys that are deleted and are in an expired state. Specifically, when the first key is determined to be in an expired state according to the expiration time through the key access process, the first key deletion instruction can be generated according to the key pointer corresponding to the first key. After executing the first key deletion instruction, the storage location of the first key in the server can be accessed according to the key pointer in the first key deletion instruction, so that the first key is deleted according to the storage location, and the total key deletion amount is accumulated by one. Further, a counter can be set in the server, and the counter is used to store the total key deletion amount. Thus, after each execution of a key deletion instruction (such as the first key deletion instruction and the second key deletion instruction in the subsequent steps), the counter accumulates the total key deletion amount by one. Further, in addition to deleting the first key in the storage location indicated by the key pointer corresponding to the first key in the server, this embodiment also deletes the first key in the preset key chain list.

[0038] S40: Obtain a first comparison time and a preset time interval, and determine whether the first time interval is greater than the preset time interval; the first time interval refers to the interval between the first comparison time and the current detection time; the current detection time is the time to start the key access process.

[0039] It can be understood that the first comparison time refers to the time corresponding to the execution of the first key deletion instruction to delete the first key, and the first comparison time is after the current detection time. The preset time interval is a custom period, that is, the deletion of expired keys is completed within the preset time interval starting from the current detection time. Exemplarily, the preset time interval can be set to 30s or 1min, etc. The first time interval refers to the interval between the first comparison time and the current detection time.

[0040] Specifically, after executing the first key deletion instruction to delete the first key and accumulating the total key deletion amount by one, obtain the preset time interval and the first comparison time currently displayed by the server. The interval between the first comparison time and the current detection time is determined as the first time interval, and the first time interval is compared with the preset time interval to determine whether the first time interval is greater than the preset time interval. If the first time interval is greater than or equal to the preset time interval, it indicates that the current time period for deleting expired keys has ended, that is, the first comparison time is not within the currently set time period. If the first time interval is less than the preset time interval, it indicates that the current time period for deleting expired keys has not ended, that is, the first comparison time is within the currently set time period.

[0041] S50: When the first time interval is smaller than the preset time interval, obtaining a preset deletion threshold, and comparing the total key deletion amount with the preset deletion threshold.

[0042] It can be understood that the preset deletion threshold is the total number of expired keys that can be deleted immediately. It should be noted that since this embodiment immediately deletes the system key in the expired state after determining that the system key (such as the first key mentioned above) is in the expired state. And deleting the system key in the expired state will occupy the system resources of the server. If there are multiple expired system keys that are deleted during the peak service period of the server, the operating efficiency of the server will be greatly reduced. Therefore, this embodiment proposes to set a preset deletion threshold according to the current system utilization rate of the server, so as to limit the maximum number of key deletion instructions that can be executed simultaneously through the preset deletion threshold.

[0043] Specifically, after determining whether the first time interval is greater than the preset time interval, if the first time interval is less than the preset time interval, it indicates that the first comparison time is still within the currently set time period. Then, the preset deletion threshold is obtained, and the total amount of key deletions is compared with the preset deletion threshold. If the total amount of key deletions is greater than or equal to the preset deletion threshold, it indicates that the total amount of system keys currently being deleted reaches or exceeds the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time. If the total amount of key deletions is less than the preset deletion threshold, it indicates that the total amount of system keys currently being deleted is less than the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time, that is, at this time, the system keys in the expired state can continue to be detected from the preset key chain list.

[0044] S60: When the total amount of key deletions is greater than or equal to the preset deletion threshold, the key access process is switched to a pause state to stop deleting the system key.

[0045] Specifically, after comparing the total amount of key deletions with the preset deletion threshold, if the total amount of key deletions is greater than or equal to the preset deletion threshold, it indicates that the total amount of system keys currently being deleted reaches or exceeds the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time. That is, at this time, it is impossible to continue to add system keys that need to be deleted and are in an expired state. There is no need to continue to access the key nodes in the preset key chain list, so the key access process can be switched to a paused state to suspend the deletion of system keys. It can be understood that after the key access process is switched to a paused state, the key access process will not continue to access the key nodes in the preset key chain list, and will not delete the system keys in the preset key chain list that are in an expired state. After the system usage rate of the server decreases, the preset deletion threshold can be adjusted so that within the currently set time period, when the total amount of key deletions is less than the adjusted preset deletion threshold, the key access process can be switched to an open state again.

[0046] In this embodiment, by setting a preset key chain list, the key nodes corresponding to each system key are sorted in the order of expiration time. In this way, the system keys in an expired state can be deleted in an orderly and accurate manner. When it is determined that the system key is in an expired state, the system key is deleted immediately, which improves the efficiency of deleting the system keys in an expired state, releases the storage pressure of the server, and improves the operation rate of the server. After the system keys in an expired state are deleted, the number of system keys in an expired state that can execute the key deletion command within the currently set time period is limited by the preset deletion threshold. In this way, when the server is in a high system utilization rate, the resource burden brought to the server by the expired key deletion process is reduced.

[0047] In one embodiment, before step S10, that is, before obtaining the preset key chain table, the following steps are included:

[0048] (1) Receiving a key lifetime setting instruction; the key lifetime setting instruction includes an expiration time interval corresponding to each of the system keys.

[0049] It is understandable that the key lifetime setting instruction can be sent by the user through the client, or it can be automatically generated after the user sends the expiration time interval corresponding to each system key through the client. Among them, the expiration time interval is a user-defined time interval, and the expiration time interval is used to limit the expiration time of the system key. Exemplarily, the expiration time interval can be set to 3 minutes or 5 minutes, etc. When the expiration time interval is 3 minutes, it means that the system key is in an expired state after 3 minutes from the time the system key is created on the server.

[0050] (2) Obtaining an initial creation time corresponding to the system key, and setting an expiration time corresponding to the system key according to the initial creation time and the expiration time interval.

[0051] It can be understood that the initial creation time indicates the time point corresponding to when the system key is created in the server. Specifically, after receiving the key lifetime setting instruction, the initial creation time corresponding to the system key can be obtained. Thus, an expiration time interval is superimposed on the initial creation time corresponding to the system key to obtain the expiration time corresponding to the system key.

[0052] (3) Obtain a key pointer corresponding to the system key, and associate the key pointer corresponding to the same system key with the expiration time and store them in the key node; one system key corresponds to one key node.

[0053] It can be understood that the key pointer is used to indicate the storage location of the system key in the server, so the key pointer can be directly obtained from the storage unit of the server. After obtaining the key pointer corresponding to the system key, the key pointer and the expiration time can be associated and stored in the key node. Furthermore, before the present embodiment, an initial key linked list can be preferentially created, and a plurality of empty key nodes are stored in the initial key linked list. That is, the key nodes in the initial key linked list do not store the expiration time and pointer corresponding to the system key. After obtaining the key pointer corresponding to the system key, the key pointer and the expiration time corresponding to the same system key can be associated and stored in any key node.

[0054] (4) Sort the key nodes in the order of the expiration time to obtain the preset key chain list.

[0055] Specifically, after the key pointer and expiration time corresponding to the same system key are associated and stored in the key node, the key nodes in the initial key chain table are now out of order. Therefore, in order to facilitate the effective detection of whether the system key is in an expired state in the subsequent steps. In this embodiment, the key nodes are sorted in the order of the expiration time to obtain a preset key chain table. If the system time of the current server is used as the standard, the key nodes corresponding to the expiration time that is closer to the system time of the server are sorted at the front end of the preset key chain table, and the key nodes corresponding to the expiration time that is farther from the system time of the server are sorted at the back end of the preset key chain table. In this way, the system keys in an expired state can be judged and deleted in an orderly and accurate manner, and the problem of the system keys in an expired state not being deleted in time will not be caused.

[0056] In one embodiment, after step S40, that is, after determining whether the first time interval is greater than the preset time interval, the method further includes:

[0057] (1) When the first time interval is greater than or equal to the preset time interval, the total number of key deletions is cleared.

[0058] Specifically, after determining whether the first time interval is greater than the preset time interval, if the first time interval is greater than or equal to the preset time interval, it indicates that the current time period for deleting expired keys has ended, that is, the first comparison time is not within the currently set time period. At this time, the total key deletion amount is cleared. It can be understood that the initial value of the total key deletion amount corresponding to each different time period is zero.

[0059] (2) Switching the key access process to a stopped state to terminate the deletion of the system key.

[0060] It can be understood that since the first time interval is greater than or equal to the preset time interval, that is, the time period for deleting the expired key is over, the key access process can be switched to the stop state at this time to terminate the deletion of the system key within the currently set time period. When the system time of the server reaches the next set time period, a new key access process can be established to complete the deletion of the expired system key.

[0061] In one embodiment, after step S50, that is, after comparing the total key deletion amount with the preset deletion threshold, the method further includes:

[0062] (1) When the total amount of key deletions is less than the preset deletion threshold, determining whether a second key is in an expired state according to the expiration time through the key access process; the second key refers to the system key corresponding to the second key node in the preset key linked list.

[0063] It can be understood that the second key refers to the system key corresponding to the second key node in the preset key list, that is, the second key is sorted after the first key. It is pointed out in the above description that when the first key is deleted from the server, the first key will be deleted from the preset key list at the same time, so the second key is the first system key in the preset key list after the first key is deleted.

[0064] Specifically, after comparing the total amount of key deletions with the preset deletion threshold, if the total amount of key deletions is less than the preset deletion threshold, it indicates that the total amount of system keys currently being deleted is less than the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time, that is, at this time, the system keys in the preset key chain list can continue to be detected in an expired state. Then, the second key is determined according to the expiration time through the key access process to determine whether the second key is in an expired state. That is, the expiration time corresponding to the second key is accessed through the key access process, and the expiration time corresponding to the second key is compared with the current system time of the server. If the current system time of the server is earlier than the expiration time corresponding to the second key, it is determined that the second key is not in an expired state. If the current system time of the server is later than the expiration time corresponding to the second key, it is determined that the second key is in an expired state.

[0065] (2) When the second key is in an expired state, execute a second key deletion instruction to delete the second key, and add one to the total number of key deletions; the second key deletion instruction is generated according to the key pointer corresponding to the second key.

[0066] Specifically, when the second key is determined to be in an expired state according to the expiration time through the key access process, a second key deletion instruction can be generated according to the key pointer corresponding to the second key. After executing the second key deletion instruction, the storage location of the second key in the server can be accessed according to the key pointer in the second key deletion instruction, so that the second key is deleted according to the storage location, and the total key deletion amount is accumulated by one. Furthermore, in addition to deleting the second key in the storage location indicated by the key pointer corresponding to the second key in the server, this embodiment also deletes the second key in the preset key chain list.

[0067] (3) Obtaining a second comparison time and determining whether a second time interval is greater than the preset time interval; the second time interval refers to the interval between the second comparison time and the current detection time.

[0068] It can be understood that the second comparison time refers to the time corresponding to when the second key deletion instruction is executed to delete the second key, and the second comparison time is after the first comparison time. The second time interval refers to the interval between the second comparison time and the current detection time.

[0069] (4) When the second time interval is less than the preset time interval, the total key deletion amount is compared with the preset deletion threshold.

[0070] Specifically, after determining whether the second time interval is greater than the preset time interval, if the second time interval is less than the preset time interval, it indicates that the second comparison time is still within the currently set time period. Then, the preset deletion threshold is obtained, and the total amount of key deletions is compared with the preset deletion threshold. If the total amount of key deletions is greater than or equal to the preset deletion threshold, it indicates that the total amount of system keys currently being deleted reaches or exceeds the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time. If the total amount of key deletions is less than the preset deletion threshold, it indicates that the total amount of system keys currently being deleted is less than the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time, that is, at this time, the system keys in the expired state can continue to be detected from the preset key chain list.

[0071] (5) When the total amount of key deletions is greater than or equal to the preset deletion threshold, the key access process is switched to a pause state to terminate the deletion of the system key.

[0072] Specifically, after comparing the total number of key deletions with the preset deletion threshold, if the total number of key deletions is greater than or equal to the preset deletion threshold, it indicates that the total number of system keys currently being deleted has reached or exceeded the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time. That is, at this time, it is impossible to continue to add expired system keys that need to be deleted. There is no need to continue accessing the key nodes in the preset key chain list, so the key access process can be switched to a paused state to stop deleting system keys.

[0073] Furthermore, if the total amount of key deletions is still less than the preset deletion threshold, the key access process continues to determine whether the third key (the third key is the system key corresponding to the third key node in the preset key list) is in an expired state according to the expiration time, and then determines whether to execute the deletion of the third key through the above steps, which will not be repeated here. That is, in the subsequent steps, as long as the current system time of the server is still within the currently set detection cycle and the total amount of key deletions is less than the preset deletion threshold, you can continue to traverse other system keys in the preset key list that are in an expired state, and execute the corresponding key deletion instructions to delete the system keys in an expired state. In this way, the number of instructions for executing key deletion instructions within a unit time (set detection cycle) (that is, the number of system keys in an expired state that are deleted) can be controlled, and when the server is in a high system utilization rate, the resource burden brought to the server by the expired key deletion process can be reduced.

[0074] In one embodiment, before step S50, that is, before obtaining the preset deletion threshold, the method further includes:

[0075] (1) Obtaining the total number of running processes in the server, and determining the system usage rate according to the total number of running processes.

[0076] It is understandable that a server may include multiple running processes, and the running processes can be considered to be in the running state. The total number of running processes is the total number of all running processes in the server. The system utilization rate represents the proportion of running processes to all processes in the server.

[0077] (2) Determine the preset deletion threshold according to the system usage rate.

[0078] It is understandable that when the system usage is high, if there are multiple system keys in an expired state that are deleted, the operating efficiency of the server will be greatly reduced. In this way, when the system usage is high, the preset deletion threshold can be set to a smaller value. For example, the preset deletion threshold can be set to 3, 4 or 5. When the system usage is low, if the preset deletion threshold is set to a lower value, the efficiency of deleting expired keys will be reduced. In this way, when the system usage is low, the preset deletion threshold can be set to a larger value. For example, the preset deletion threshold can be set to 10, 11 or 12, etc.

[0079] In this embodiment, the preset deletion threshold is dynamically set according to the system utilization of the server. When the system utilization of the server is low, a higher preset deletion threshold can be set, thereby improving the efficiency of deleting expired system keys. When the system utilization of the server is high, the resource burden of the expired key deletion process on the server is reduced.

[0080] In one embodiment, after switching the key access process to a paused state, the method further includes:

[0081] (1) Acquire the current comparison time in real time and determine whether the current comparison time exceeds the target detection time; the target detection time is the time corresponding to a preset time interval after the current detection time.

[0082] It can be understood that the current comparison time is the current system time of the server, and the current comparison time will change accordingly over time. The target detection time is the time point corresponding to the preset time interval after the current detection time, that is, the interval between the target detection time and the current detection time is the preset time interval. When the current comparison time exceeds the target detection time, it indicates that the currently set detection cycle has ended. When the current comparison time does not exceed the target detection time, it indicates that the currently set detection cycle has not yet ended.

[0083] (2) When the current comparison time does not exceed the target detection time, the system usage rate of the server is obtained in real time, and the preset deletion threshold is adjusted according to the system usage rate to obtain an adjusted deletion threshold.

[0084] Specifically, after determining whether the current comparison time exceeds the target detection time, if the current comparison time does not exceed the target detection time, it indicates that the currently set detection cycle has not ended. Then, the system usage rate of the server can be obtained in real time, so that the preset deletion threshold can be adjusted in real time according to the system usage rate obtained in real time to obtain the adjusted deletion threshold. As time goes by, there is a possibility that the system usage rate of the server will decrease. Then, when the system usage rate of the server decreases, more system keys in an expired state can be deleted within a detection cycle by dynamically adjusting the preset deletion threshold. Further, the preset deletion threshold can be adjusted according to the system usage rate corresponding to the setting of the preset deletion threshold and the difference between the currently obtained system usage rate. For example, the historical system usage rate is 90%, and the preset deletion threshold corresponding to the historical system usage rate is 3. When the currently obtained system usage rate is 50%, the difference in system usage rate is 40%, and the preset deletion threshold can be adjusted to 7.

[0085] (3) Compare the total key deletion amount with the adjusted deletion threshold.

[0086] (4) Before the current comparison time exceeds the target detection time, the total key deletion amount continues to be greater than or equal to the adjusted deletion threshold, the key access process is switched to a stopped state, and the total key deletion amount is cleared.

[0087] Specifically, after the preset deletion threshold is adjusted according to the system usage rate and the adjusted deletion threshold is obtained, the total key deletion amount is compared with the adjusted deletion threshold. It can be understood that in this embodiment, the system usage rate is obtained in real time, and the preset deletion threshold is adjusted according to the system usage rate obtained in real time, so the obtained adjusted deletion threshold will change over time. Therefore, before the current comparison time exceeds the target detection time, if the total key deletion amount continues to be greater than or equal to the adjusted deletion threshold, it means that within the currently set detection cycle, the total amount of system keys currently being deleted continues to reach or exceed the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time. Then, the key access process can be switched to a stopped state to indicate that the currently set detection cycle has ended, and the total key deletion amount can be cleared.

[0088] In one embodiment, after comparing the total key deletion amount with the adjusted deletion threshold, the method further includes:

[0089] Before the current comparison time exceeds the target detection time, if the total amount of key deletions is less than the adjusted deletion threshold, the key access process is switched to the on state, and the key access process is used to determine whether the second key is in an expired state according to the expiration time; the second key refers to the system key corresponding to the second key node in the preset key list.

[0090] Specifically, after comparing the total amount of key deletions with the adjustment deletion threshold, before the current comparison time exceeds the target detection time, that is, the current comparison time is still within the currently set detection cycle. If there is an adjustment deletion threshold at any time that is greater than the total amount of key deletions, it indicates that the total amount of system keys currently being deleted is less than the maximum number of system keys that the server can currently bear to execute key deletion instructions at the same time, that is, at this time, the system keys in the expired state can continue to be detected from the preset key chain list. Then, the key access process can be switched to the on state, and the key access process is used to determine whether the second key is in an expired state according to the expiration time. That is, the expiration time corresponding to the second key is accessed through the key access process, and the expiration time corresponding to the second key is compared with the current system time of the server. If the current system time of the server is earlier than the expiration time corresponding to the second key, it is determined that the second key is not in an expired state. If the current system time of the server is later than the expiration time corresponding to the second key, it is determined that the second key is in an expired state.

[0091] When the second key is in an expired state, a second key deletion instruction is executed to delete the second key, and the total key deletion amount is increased by one; the second key deletion instruction is generated according to the key pointer corresponding to the second key.

[0092] Specifically, when the second key is determined to be in an expired state according to the expiration time through the key access process, a second key deletion instruction can be generated according to the key pointer corresponding to the second key. After executing the second key deletion instruction, the storage location of the second key in the server can be accessed according to the key pointer in the second key deletion instruction, so that the second key is deleted according to the storage location, and the total key deletion amount is accumulated by one. Furthermore, in addition to deleting the second key in the storage location indicated by the key pointer corresponding to the second key in the server, this embodiment also deletes the second key in the preset key chain list.

[0093] The key deletion total is compared to the adjusted deletion threshold.

[0094] When the total amount of key deletions is greater than or equal to the adjusted deletion threshold, the key access process is switched to a pause state to suspend deletion of the system key.

[0095] Specifically, after executing the second key deletion instruction to delete the second key and accumulating the total key deletion amount to one, the total key deletion amount is compared with the adjustment deletion threshold. If the total key deletion amount is greater than or equal to the adjustment deletion threshold at this time, the key access process is switched to a paused state to suspend the deletion of the system key. Furthermore, if the current comparison time does not exceed the target detection time, the adjustment deletion threshold can continue to be modified to determine whether other system keys in an expired state can continue to be deleted. The specific execution steps are the same as the above method and will not be repeated here.

[0096] Furthermore, if the total amount of key deletions is greater than or equal to the adjusted deletion threshold, and the current comparison time exceeds the target detection time, the key access process can be switched to a stopped state to indicate that the currently set detection cycle has ended, and the total amount of key deletions can be cleared. In this way, the method of dynamically adjusting the preset deletion threshold according to the real-time system usage can improve the efficiency of deleting expired system keys.

[0097] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0098] In one embodiment, an expired key deletion device is provided, and the expired key deletion device corresponds to the expired key deletion method in the above embodiment. Figure 3 As shown, the device includes a linked list acquisition module 10, a first detection module 20, a first deletion module 30, a first comparison module 40, a first comparison module 50 and a first suspension module 60. The functional modules are described in detail as follows:

[0099] The chain list acquisition module 10 is used to acquire a preset key chain list and detect whether the preset key chain list is empty; the preset key chain list is used to store key nodes of the system key; one of the key nodes includes a key pointer and an expiration time corresponding to the system key;

[0100] A first detection module 20, configured to start a key access process when the preset key chain list is not empty, so as to determine whether a first key is in an expired state according to the expiration time through the key access process; the first key refers to a system key corresponding to the key node ranked first in the preset key chain list;

[0101] A first deletion module 30, configured to execute a first key deletion instruction to delete the first key when the first key is in an expired state, and to accumulate a total key deletion amount by one; the first key deletion instruction is generated according to a key pointer corresponding to the first key;

[0102] A first comparison module 40 is used to obtain a first comparison time and a preset time interval, and determine whether the first time interval is greater than the preset time interval; the first time interval refers to the interval between the first comparison time and the current detection time; the current detection time is the time when the key access process is started;

[0103] A first comparison module 50, configured to obtain a preset deletion threshold when the first time interval is less than the preset time interval, and compare the total key deletion amount with the preset deletion threshold;

[0104] The first pause module 60 is used to switch the key access process to a pause state to stop deleting the system key when the total key deletion amount is greater than or equal to the preset deletion threshold.

[0105] Preferably, the expired key deletion device further comprises:

[0106] An instruction receiving module, used for receiving a key life time setting instruction; the key life time setting instruction includes an expiration time interval corresponding to each of the system keys;

[0107] An expiration time setting module, used to obtain the initial creation time corresponding to the system key, and set the expiration time corresponding to the system key according to the initial creation time and the expiration time interval;

[0108] A data storage module, used for obtaining a key pointer corresponding to the system key, and associating the key pointer corresponding to the same system key with the expiration time and storing them in the key node; one system key corresponds to one key node;

[0109] The node sorting module is used to sort the key nodes in the order of the expiration time to obtain the preset key chain list.

[0110] Preferably, the expired key deletion device further comprises:

[0111] A data clearing module, used for clearing the total key deletion amount when the first time interval is greater than or equal to the preset time interval;

[0112] The process state switching module is used to switch the key access process to a stop state to terminate the deletion of the system key.

[0113] Preferably, the expired key deletion device further comprises:

[0114] A second detection module is used to determine whether a second key is in an expired state according to the expiration time through the key access process when the total amount of key deletions is less than the preset deletion threshold; the second key refers to the system key corresponding to the second key node in the preset key chain list;

[0115] A second deletion module is used to execute a second key deletion instruction to delete the second key when the second key is in an expired state, and to accumulate the total number of key deletions by one; the second key deletion instruction is generated according to the key pointer corresponding to the second key;

[0116] A second comparison module, used to obtain a second comparison time, and determine whether a second time interval is greater than the preset time interval; the second time interval refers to the interval between the second comparison time and the current detection time;

[0117] A second comparison module, configured to compare the total key deletion amount with the preset deletion threshold when the second time interval is less than the preset time interval;

[0118] The second pause module is used to switch the key access process to a pause state to stop deleting the system key when the total key deletion amount is greater than or equal to the preset deletion threshold.

[0119] Preferably, the expired key deletion device further comprises:

[0120] A system usage rate determination module, used to obtain the total number of running processes of the running processes in the server, and determine the system usage rate according to the total number of running processes;

[0121] A threshold determination module is used to determine the preset deletion threshold according to the system usage rate.

[0122] Preferably, the expired key deletion device further comprises:

[0123] A third comparison module is used to obtain the current comparison time in real time and determine whether the current comparison time exceeds the target detection time; the target detection time is the time corresponding to the preset time interval after the current detection time;

[0124] A threshold adjustment module, used to obtain the system usage rate of the server in real time when the current comparison time does not exceed the target detection time, and adjust the preset deletion threshold according to the system usage rate to obtain an adjusted deletion threshold;

[0125] A third comparison module, configured to compare the total key deletion amount with the adjusted deletion threshold;

[0126] The process stop module is used to switch the key access process to a stop state and clear the total key deletion amount if the total key deletion amount is continuously greater than or equal to the adjustment deletion threshold before the current comparison time exceeds the target detection time.

[0127] Preferably, the expired key deletion device further comprises:

[0128] A process start module, used for switching the key access process to the start state before the current comparison time exceeds the target detection time, if the total amount of key deletions is less than the adjustment deletion threshold, and determining whether the second key is in an expired state according to the expiration time through the key access process; the second key refers to the system key corresponding to the second key node in the preset key chain list;

[0129] A third deletion module is used to execute a second key deletion instruction to delete the second key when the second key is in an expired state, and to accumulate the total number of key deletions by one; the second key deletion instruction is generated according to the key pointer corresponding to the second key;

[0130] A fourth comparison module, configured to compare the total key deletion amount with the adjusted deletion threshold;

[0131] The third pause module is used to switch the key access process to a pause state to stop deleting the system key when the total key deletion amount is greater than or equal to the adjustment deletion threshold.

[0132] For the specific definition of the expired key deletion device, please refer to the definition of the expired key deletion method above, which will not be repeated here. The various modules in the above-mentioned expired key deletion device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0133] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes 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 the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data used by the expired key deletion method in the above embodiment. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an expired key deletion method is implemented.

[0134] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the expired key deletion method in the above embodiment is implemented.

[0135] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the expired key deletion method in the above embodiment is implemented.

[0136] 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, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0137] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0138] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A method for deleting expired keys, characterized in that: include: Obtaining a preset key chain table, and detecting whether the preset key chain table is empty; the preset key chain table is used to store key nodes of system keys; One of the key nodes includes a key pointer and an expiration time corresponding to a system key; When the preset key chain list is not empty, start a key access process to determine whether a first key is in an expired state according to the expiration time through the key access process; the first key refers to a system key corresponding to the key node ranked first in the preset key chain list; When the first key is in an expired state, executing a first key deletion instruction to delete the first key, and accumulating the total number of key deletions by one; the first key deletion instruction is generated according to the key pointer corresponding to the first key; Obtain a first comparison time and a preset time interval, and determine whether the first time interval is greater than the preset time interval; the first time interval refers to the interval between the first comparison time and the current detection time; the current detection time is the time when the key access process is started; When the first time interval is less than the preset time interval, obtaining a preset deletion threshold, and comparing the total key deletion amount with the preset deletion threshold; When the total amount of key deletion is greater than or equal to the preset deletion threshold, switching the key access process to a pause state to suspend deletion of the system key; Before obtaining the preset key chain list, the method includes: receiving a key lifetime setting instruction; the key lifetime setting instruction including an expiration time interval corresponding to each of the system keys; Obtaining an initial creation time corresponding to the system key, and setting an expiration time corresponding to the system key according to the initial creation time and the expiration time interval; Obtaining a key pointer corresponding to the system key, and associating the key pointer corresponding to the same system key with the expiration time and storing them in the key node; one system key corresponds to one key node; The key nodes are sorted in the order of the expiration time to obtain the preset key chain list.

2. The expired key deletion method according to claim 1, characterized in that: After determining whether the first time interval is greater than the preset time interval, the method further includes: When the first time interval is greater than or equal to the preset time interval, clearing the total key deletion amount; The key access process is switched to a stopped state to terminate the deletion of the system key.

3. The expired key deletion method according to claim 1, characterized in that: After comparing the total key deletion amount with the preset deletion threshold, the method further includes: When the total amount of key deletions is less than the preset deletion threshold, determining whether a second key is in an expired state according to the expiration time through the key access process; the second key refers to the system key corresponding to the second key node in the preset key chain list; When the second key is in an expired state, executing a second key deletion instruction to delete the second key, and accumulating the total number of key deletions by one; the second key deletion instruction is generated according to the key pointer corresponding to the second key; Obtaining a second comparison time, and determining whether a second time interval is greater than the preset time interval; the second time interval refers to the interval between the second comparison time and the current detection time; When the second time interval is less than the preset time interval, comparing the total key deletion amount with the preset deletion threshold; When the total amount of key deletions is greater than or equal to the preset deletion threshold, the key access process is switched to a pause state to stop deleting the system key.

4. The expired key deletion method according to claim 1, characterized in that: Before obtaining the preset deletion threshold, the method further includes: Obtaining the total number of running processes of the processes in the running state in the server, and determining the system usage rate according to the total number of running processes; The preset deletion threshold is determined according to the system usage rate.

5. The expired key deletion method according to claim 1, characterized in that: include: After switching the key access process to a pause state, the method further includes: Acquire the current comparison time in real time, and determine whether the current comparison time exceeds the target detection time; the target detection time is the time corresponding to the preset time interval after the current detection time; When the current comparison time does not exceed the target detection time, obtaining a system usage rate of the server in real time, and adjusting the preset deletion threshold according to the system usage rate to obtain an adjusted deletion threshold; comparing the total key deletion amount to the adjusted deletion threshold; Before the current comparison time exceeds the target detection time, the total key deletion amount continues to be greater than or equal to the adjusted deletion threshold, the key access process is switched to a stopped state, and the total key deletion amount is cleared.

6. The expired key deletion method according to claim 5, characterized in that: After comparing the total key deletion amount with the adjusted deletion threshold, the method further includes: Before the current comparison time exceeds the target detection time, if the total amount of key deletions is less than the adjusted deletion threshold, the key access process is switched to an on state, and the key access process is used to determine whether the second key is in an expired state according to the expiration time; the second key refers to the system key corresponding to the second key node in the preset key chain list; When the second key is in an expired state, executing a second key deletion instruction to delete the second key, and accumulating the total number of key deletions by one; the second key deletion instruction is generated according to the key pointer corresponding to the second key; comparing the total key deletion amount to the adjusted deletion threshold; When the total amount of key deletions is greater than or equal to the adjusted deletion threshold, the key access process is switched to a pause state to suspend deletion of the system key.

7. An expired key deletion device, characterized in that: The expired key deletion device is used to execute the expired key deletion method according to any one of claims 1 to 6, and the expired key deletion device includes: A linked list acquisition module, used to acquire a preset key linked list and detect whether the preset key linked list is empty; the preset key linked list is used to store key nodes of system keys; one of the key nodes includes a key pointer and an expiration time corresponding to the system key; A first detection module, configured to start a key access process when the preset key chain list is not empty, so as to determine whether a first key is in an expired state according to the expiration time through the key access process; the first key refers to a system key corresponding to the key node ranked first in the preset key chain list; A first deletion module, configured to, when the first key is in an expired state, execute a first key deletion instruction to delete the first key, and accumulate a total key deletion amount by one; the first key deletion instruction is generated according to a key pointer corresponding to the first key; A first comparison module, used to obtain a first comparison time and a preset time interval, and determine whether the first time interval is greater than the preset time interval; the first time interval refers to the interval between the first comparison time and the current detection time; the current detection time is the time when the key access process is started; A first comparison module, configured to obtain a preset deletion threshold when the first time interval is less than the preset time interval, and compare the total key deletion amount with the preset deletion threshold; The first pause module is used to switch the key access process to a pause state to stop deleting the system key when the total key deletion amount is greater than or equal to the preset deletion threshold.

8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the expired key deletion method as described in any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the expired key deletion method as described in any one of claims 1 to 6 is implemented.