A method and device for delayed deletion of data
By generating delayed deletion flag bits in the cache system and setting their survival time, the problem of inconsistency between the cache system data and the database data is solved, improving data deletion efficiency and reducing performance overhead.
Patent Information
- Application Number
- CN202410935161.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2044-07-12
AI Technical Summary
In Internet application systems, due to concurrent requests and other reasons, the cached system data is inconsistent with the database data, causing users to query dirty data, and the performance overhead brought by the delayed double deletion strategy is high, resulting in inefficient data deletion.
By generating the delay deletion flag bit in the cache system and storing it in the cache system, setting the delay deletion time as the survival time of the flag bit, deleting the cache data after the survival time expires; if the current delay deletion time is greater than the preset time, the data to be written is stored in the cache system, and its survival time is set to the current delay deletion time.
By reducing unnecessary deletion operations and waiting time, data deletion efficiency is improved, delays caused by thread blocking are avoided, and the overall performance of the system is improved.
Smart Images

Figure CN118779347B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method and device for delayed deletion of data. Background Art
[0002] When the number of visits to an Internet application system increases dramatically, the database query pressure will increase. To solve this problem, we usually use a cache system to store database data. However, when updating the cache system data, due to concurrent requests and other reasons, the cache system data may be inconsistent with the database data, which means that users may query dirty data (that is, data that does not meet specific standards or cannot be used directly). In order to reduce the problem of dirty data, a delayed double deletion strategy is generally adopted.
[0003] Delayed double deletion is a strategy to maintain data consistency between database and cache systems in a distributed system. All operations are performed sequentially in the same thread, including deleting the cache, updating the database, and deleting the cache again, and a waiting time is set after updating the database. However, this method may bring additional performance overhead because it requires two deletion operations and includes a waiting time, which may cause the request that can be completed in tens of milliseconds to be extended to 3 to 5 seconds, resulting in inefficient data deletion.
[0004] Therefore, how to improve the efficiency of data deletion has become an urgent problem to be solved in this field. Summary of the invention
[0005] The present application provides a method and device for delayed deletion of data, aiming to improve the efficiency of data deletion.
[0006] In order to achieve the above objectives, this application provides the following technical solutions:
[0007] A delayed deletion method for data, comprising:
[0008] When a data deletion request is received, cache data corresponding to the data deletion request is obtained from the cache system, and a delayed deletion time is obtained from a configuration file;
[0009] Generating a delayed deletion flag based on the cache data, and storing the delayed deletion flag in the cache system;
[0010] The delayed deletion time is set to the survival time of the delayed deletion flag;
[0011] When the survival time is set, the cache data in the cache system is deleted;
[0012] When a data read request is received, the data to be written is obtained from the database;
[0013] If the current delayed deletion time is greater than the preset time, the data to be written is stored in the cache system, and the current delayed deletion time is set as the survival time of the data to be written; the current delayed deletion time indicates the remaining survival time of the delayed deletion flag in the cache system;
[0014] If the survival time of the data to be written is not greater than the preset time, the data to be written and the delayed deletion flag in the cache system are deleted.
[0015] Optionally, generating a delayed deletion flag based on the to-be-deleted data, and storing the delayed deletion flag in the cache system, includes:
[0016] Extracting key information from the cached data;
[0017] Generate a cache KEY based on the key information;
[0018] A preset suffix is added to the cache KEY to obtain a delayed deletion flag, and the delayed deletion flag is stored in the cache system.
[0019] Optionally, if the current delayed deletion time is greater than a preset time, storing the data to be written into the cache system, and setting the current delayed deletion time to be before the survival time of the data to be written, includes:
[0020] Read key information from the data to be written, and generate a cache KEY based on the key information;
[0021] Adding a preset suffix to the cache KEY to obtain a delayed deletion flag;
[0022] Read the current delayed deletion time of the delayed deletion flag.
[0023] Optionally, when receiving a data read request, after obtaining the data to be written from the database, the method further includes:
[0024] Obtain a configuration file, and obtain a cache survival time from the configuration file;
[0025] If the current delayed deletion time is not greater than the preset time, the data to be written is stored in the cache system, and the cache survival time is set to the survival time of the data to be written;
[0026] When the survival time of the data to be written is not greater than the preset time, the data to be written in the cache system is deleted.
[0027] Optionally, when receiving a data deletion request, obtaining cache data corresponding to the data deletion request from the cache system, and obtaining the delayed deletion time from the configuration file, further includes:
[0028] When receiving a data read request, determining whether there is cache data corresponding to the data read request in the cache system;
[0029] If cache data corresponding to the data read request exists in the cache system, the cache data corresponding to the data read request is acquired from the cache system.
[0030] A device for delayed deletion of data, comprising:
[0031] A first acquisition unit, configured to, when receiving a data deletion request, acquire cache data corresponding to the data deletion request from a cache system, and acquire a delayed deletion time from a configuration file;
[0032] A generating unit, configured to generate a delayed deletion flag based on the cache data, and store the delayed deletion flag in the cache system;
[0033] A setting unit, used to set the delayed deletion time to the survival time of the delayed deletion flag;
[0034] A first deleting unit, configured to delete the cache data in the cache system after the survival time is set;
[0035] A second acquisition unit, configured to acquire the data to be written from the database when receiving a data read request;
[0036] A storage unit, configured to store the data to be written into the cache system if the current delayed deletion time is greater than a preset time, and set the current delayed deletion time as the survival time of the data to be written; the current delayed deletion time indicates the remaining survival time of the delayed deletion flag in the cache system;
[0037] The second deleting unit is used to delete the data to be written and the delayed deletion flag in the cache system if the survival time of the data to be written is not greater than the preset time.
[0038] Optionally, the generating unit is specifically used for:
[0039] Extracting key information from the cached data;
[0040] Generate a cache KEY based on the key information;
[0041] A preset suffix is added to the cache KEY to obtain a delayed deletion flag, and the delayed deletion flag is stored in the cache system.
[0042] Optionally, also include:
[0043] An information generating unit, configured to read key information from the data to be written, and generate a cache KEY based on the key information;
[0044] An adding unit, used for adding a preset suffix to the cache KEY to obtain a delayed deletion flag;
[0045] A reading unit is used to read the current delayed deletion time of the delayed deletion flag.
[0046] Optionally, also include:
[0047] A file acquisition unit, used to acquire a configuration file and obtain a cache survival time from the configuration file;
[0048] A data storage unit, configured to store the data to be written into the cache system if the current delayed deletion time is not greater than a preset time, and to set the cache survival time to the survival time of the data to be written;
[0049] The third deleting unit is used to delete the data to be written in the cache system when the survival time of the data to be written is not greater than the preset time.
[0050] Optionally, also include:
[0051] A determination unit, configured to determine, when receiving a data read request, whether there is cache data corresponding to the data read request in the cache system;
[0052] The third acquisition unit is configured to acquire the cache data corresponding to the data read request from the cache system if the cache data corresponding to the data read request exists in the cache system.
[0053] The technical solution provided by the present application, when receiving a data deletion request, obtains the cache data corresponding to the data deletion request from the cache system, and obtains the delayed deletion time from the configuration file; generates a delayed deletion flag based on the cache data, and stores the delayed deletion flag in the cache system; sets the delayed deletion time to the survival time of the delayed deletion flag; when the survival time is set, deletes the cache data in the cache system; when receiving a data read request, obtains the data to be written from the database; if the current delayed deletion time is greater than the preset time, stores the data to be written in the cache system, and sets the current delayed deletion time to the survival time of the data to be written; if the survival time of the data to be written is not greater than the preset time, deletes the data to be written and the delayed deletion flag in the cache system. In the present application, by setting the current delayed deletion time as the survival time of the data to be written, if the survival time of the data to be written is not greater than the preset time, the data to be written in the cache system is directly deleted, and there is no need to wait for 3 to 5 seconds before deleting due to thread blocking, thereby improving the efficiency of data deletion. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0055] Figure 1 A flowchart of a method for delayed deletion of data provided in an embodiment of the present application;
[0056] Figure 2 A flowchart of a flag bit generation method provided in an embodiment of the present application;
[0057] Figure 3 A flowchart of a method for deleting data to be written provided in an embodiment of the present application;
[0058] Figure 4 A flowchart of a method for reading delayed deletion time provided in an embodiment of the present application;
[0059] Figure 5 A schematic diagram of the architecture of a device for delayed deletion of data provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0061] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.
[0062] like Figure 1 FIG. 1 is a flowchart of a method for delayed deletion of data provided in an embodiment of the present application, comprising the following steps:
[0063] S101: When a data deletion request is received, cache data corresponding to the data deletion request is obtained from a cache system, and a delayed deletion time is obtained from a configuration file.
[0064] The data deletion request indicates a request to delete cached data in the cache system.
[0065] Optionally, the configuration file of the application is read first, and then the delayed deletion time is obtained from the configuration file. The delayed deletion time indicates the time for delaying the deletion of the relevant information in the cache system.
[0066] Optionally, before step S101, before receiving the data deletion request, cache data is pre-stored in the cache system. At this time, when a data read request is received, the data can be directly read from the cache system without accessing the database to obtain the data, thereby reducing the database query pressure. Therefore, another embodiment of the present application provides a method for obtaining cache data, including:
[0067] When a data read request is received, it is determined whether there is cache data corresponding to the data read request in the cache system.
[0068] It can be understood that when a business operation reads data, that is, when a data read request is received, it first checks whether the cache data corresponding to the data read request exists in the cache system. If so, it means that the cache is hit, then the data can be read directly from the cache system; if not, then it is necessary to obtain the data from the database.
[0069] If cache data corresponding to the data read request exists in the cache system, the cache data corresponding to the data read request is obtained from the cache system.
[0070] It should be noted that if the data corresponding to the data read request exists in the cache system, the data corresponding to the data read request can be directly obtained from the cache system without accessing the database, thereby reducing the query pressure on the database.
[0071] S102: Generate a delayed deletion flag based on the cache data, and store the delayed deletion flag in the cache system.
[0072] Wherein, a delayed deletion flag is generated based on the cache data. Specifically, a cache KEY is generated based on the cache data; and the cache KEY is marked to obtain a delayed deletion flag.
[0073] It should be noted that in some scenarios, directly deleting data may result in a large amount of database operations or computing overhead. By storing the delayed deletion flag in the cache system, the actual data deletion operation can be delayed, thereby reducing frequent access to the database and improving the overall performance and response speed of the system.
[0074] Optionally, in another embodiment of the present application, the specific implementation of step S102 is as follows: Figure 2 As shown, the following steps are included:
[0075] S201: Extract key information from cache data.
[0076] The key information indicates the id of the User object (ie, an entity used to store and manage user-related information in an application).
[0077] It should be noted that the modification or deletion of data is performed in the database. These operations are performed in a database transaction, so they will not be directly reflected in the persistent state of the database until the transaction is committed. After the database transaction is executed (but before it is committed), key information is first extracted from the cached data.
[0078] S202: Generate a cache KEY based on the key information.
[0079] The cache KEY is used to identify the corresponding item in the cache system for the changed data in the database.
[0080] For example, the id of the User object is 1, and the cache key is generated based on the key information, so the cache key is user:1.
[0081] S203: Add a preset suffix to the cache KEY to obtain a delayed deletion flag, and store the delayed deletion flag in the cache system.
[0082] Optionally, the preset suffix includes but is not limited to: “:@d”.
[0083] For example, the cache KEY is user:1, and the preset suffix is ":@d". The preset suffix is added to the cache KEY to obtain the delayed deletion flag "user:1:@d", and the delayed deletion flag is stored in the cache system.
[0084] S103: Setting the delayed deletion time to the survival time of the delayed deletion flag.
[0085] It is understandable that the delayed deletion time is set to the survival time of the delayed deletion flag, that is, the survival time of the delayed deletion flag in the cache system. The purpose of setting the survival time of the delayed deletion flag is to control the validity period of the delayed deletion flag in the cache system, ensure that the data deletion operation can be completed within a certain period of time, and avoid unnecessary resource occupation or data consistency problems caused by the long-term existence of the delayed deletion flag.
[0086] For example, the delayed deletion flag is "user:1:@d", the delayed deletion time is 5 seconds, and the delayed deletion time is set to the survival time of the delayed deletion flag, indicating that the user data with id 1 will be deleted after 5 seconds (that is, the delayed deletion flag will be deleted after 5 seconds).
[0087] S104: After the survival time is set, the cache data in the cache system is deleted.
[0088] Among them, when the survival time is set, the cache data in the cache system is deleted through the cache KEY. At this time, only the delayed deletion flag is stored in the cache system, and the cache data has been deleted, that is, the first deletion of the cache data is completed.
[0089] S105: When a data read request is received, the data to be written is obtained from the database.
[0090] Among them, when a data read request is received, since the cached data in the cache system has been deleted, the data corresponding to the read request cannot be obtained from the cache system. Therefore, at this time, only the data to be written corresponding to the data read request can be obtained from the database, and the data write operation is performed on the data to be written.
[0091] Optionally, after step S105, there is still a situation where the current delayed deletion time is not greater than the preset time. In this case, the survival time of the data to be written to the cache system needs to be reset, and after the survival time is not greater than the preset time, the data to be written in the cache system needs to be deleted. Therefore, another embodiment of the present application provides a method for deleting data to be written, such as Figure 3 As shown, the following steps are included:
[0092] S301: Obtain a configuration file, and obtain the cache survival time from the configuration file.
[0093] The cache survival time indicates the time (ie, expiration time) that the cache survives in the cache system. The cache survival time includes but is not limited to: 6 hours, 12 hours, and 24 hours.
[0094] S302: If the current delayed deletion time is not greater than the preset time, the data to be written is stored in the cache system, and the cache survival time is set to the survival time of the data to be written.
[0095] The preset time includes but is not limited to: 0 seconds.
[0096] It is understandable that if the current delayed deletion time is not greater than the preset time, it means that the delayed deletion flag does not exist at this time, the data to be written is stored in the cache system, and the cache survival time is set to the survival time of the data to be written.
[0097] S303: When the survival time of the data to be written is not greater than the preset time, the data to be written in the cache system is deleted.
[0098] It should be noted that since the capacity of the cache system is limited, it is necessary to regularly check and clean up expired cache data to prevent cache overflow or performance degradation due to long-term storage of large amounts of data. By setting the cache survival time to the survival time of the data to be written, the data to be written will be deleted after the cache survival time expires (that is, when the survival time of the data to be written is not greater than the preset time).
[0099] For example, if the cache survival time is 6 hours, the cache survival time is set to the survival time of the data to be written. After 6 hours, the written data will be deleted from the cache system.
[0100] S106: If the current delayed deletion time is greater than the preset time, the data to be written is stored in the cache system, and the current delayed deletion time is set as the survival time of the data to be written.
[0101] The current delayed deletion time indicates the remaining survival time of the delayed deletion flag in the cache system.
[0102] It is understandable that if the current delayed deletion time is greater than the preset time, it means that the delayed deletion flag exists, then the data to be written is stored in the cache system, and the current delayed deletion time is set as the survival time of the data to be written.
[0103] It should be noted that the data to be written with the same user object ID value within the delayed deletion time is stored in the cache system. Due to the disorder of thread execution, a thread that starts first may be executed later, and a thread that starts later may be executed first. In this case, the data to be written may be dirty data or normal data. In order to ensure that the subsequent cache is normal data rather than dirty data, the current delayed deletion time is set to the survival time of the data to be written. When the current delayed deletion time is not greater than the preset time, the data to be written and the delayed deletion flag are deleted.
[0104] Among them, dirty data refers to data that does not meet specific standards or cannot be used directly.
[0105] Optionally, before step S106, the current delayed deletion time needs to be read so that the survival time of the data to be written can be determined based on the current delayed deletion time, which can reduce the occurrence of inconsistencies or errors caused by premature data writing. Therefore, a method for reading the current delayed deletion time is provided in the embodiment of the present application, such as Figure 4 As shown, the following steps are included:
[0106] S401: Read key information from the data to be written, and generate a cache KEY based on the key information.
[0107] Some programming languages or frameworks may use object references when managing objects in memory. If the user objects returned by multiple data read operations are actually references to the same object, their ID values are the same because they point to the object at the same memory address, which means that the key information read from the cached data and the data to be written is consistent.
[0108] S402: Add a preset suffix to the cache KEY to obtain a delayed deletion flag.
[0109] It should be noted that the specific implementation of step S402 may refer to step S203 accordingly, and will not be described in detail here.
[0110] S403: Read the current delayed deletion time of the delayed deletion flag.
[0111] The current delayed deletion time of the read delayed deletion flag is the remaining survival time of the read delayed deletion flag in the cache system.
[0112] It should be noted that the current delayed deletion time is generally less than the delayed deletion time. For example, if the delayed deletion time is 5 seconds, the current delayed deletion time may be 4 seconds, or 3 seconds, or 2 seconds, or 1 second, or 0 seconds.
[0113] S107: If the survival time of the data to be written is not greater than the preset time, the data to be written and the delayed deletion flag in the cache system are deleted.
[0114] Among them, if the survival time of the data to be written is not greater than the preset time, it means that the delayed deletion flag and the data to be written have expired. At this time, the data to be written and the delayed deletion flag in the cache system are deleted (that is, the secondary deletion operation is completed) to ensure that the dirty data of the current delayed deletion time appears in the cache system at most.
[0115] It should be noted that since the data modification or deletion operations are all performed in the database transaction, after completing the secondary deletion operation, the database transaction is committed to make the modification or deletion operation in the database officially take effect. If the secondary deletion operation is not completed correctly, the transaction will be rolled back to the original state.
[0116] It should be emphasized that steps S101 to S107 use Redis scripts because Redis supports script execution, especially through the Lua language, which allows us to perform a series of complex logical operations in the Redis environment, and these operations are atomic, that is, they will not be interrupted by other commands during execution. Therefore, when implementing the delayed deletion operation of the cache, we can use the Lua script function of Redis to ensure the atomicity and consistency of the operation.
[0117] To sum up, by setting the current delayed deletion time to the survival time of the data to be written, if the survival time of the data to be written is not greater than the preset time, the data to be written in the cache system is directly deleted. There is no need to wait for 3 to 5 seconds before deletion due to thread blocking, thus improving data deletion efficiency.
[0118] like Figure 5 As shown, it is a schematic diagram of the architecture of a delayed deletion device for data provided in an embodiment of the present application, and the delayed deletion device includes: a first acquisition unit 100, a generation unit 200, a setting unit 300, a first deletion unit 400, a second acquisition unit 500, a storage unit 600 and a second deletion unit 700.
[0119] The first acquisition unit 100 is used to acquire cache data corresponding to the data deletion request from the cache system and acquire the delayed deletion time from the configuration file when receiving the data deletion request.
[0120] The generating unit 200 is used to generate a delayed deletion flag based on cache data, and store the delayed deletion flag in the cache system.
[0121] The generation unit 200 is specifically used to: extract key information from cache data; generate a cache KEY based on the key information; add a preset suffix to the cache KEY to obtain a delayed deletion flag, and store the delayed deletion flag in the cache system.
[0122] The setting unit 300 is used to set the delayed deletion time as the survival time of the delayed deletion flag.
[0123] The first deleting unit 400 is used to delete cache data in the cache system after the survival time is set.
[0124] The second acquisition unit 500 is used to acquire the data to be written from the database when receiving a data read request.
[0125] Storage unit 600 is used to store the data to be written in the cache system if the current delayed deletion time is greater than the preset time, and set the current delayed deletion time as the survival time of the data to be written; the current delayed deletion time indicates the remaining survival time of the delayed deletion flag in the cache system.
[0126] The second deleting unit 700 is used to delete the data to be written and the delayed deletion flag in the cache system if the survival time of the data to be written is not greater than a preset time.
[0127] To sum up, by setting the current delayed deletion time as the survival time of the data to be written, if the survival time of the data to be written is not greater than the preset time, the data to be written in the cache system is directly deleted. There is no need to wait for 3 to 5 seconds before deletion due to thread blocking, thus improving data deletion efficiency.
[0128] Preferably, combined Figure 5 As shown in the content, the delayed deletion device also includes: an information generating unit, an adding unit and a reading unit.
[0129] The information generation unit is used to read key information from the data to be written and generate a cache KEY based on the key information.
[0130] The adding unit is used to add a preset suffix to the cache KEY to obtain a delayed deletion flag.
[0131] The reading unit is used to read the current delayed deletion time of the delayed deletion flag.
[0132] Preferably, combined Figure 5 As shown in the content, the delayed deletion device also includes: a file acquisition unit, a data storage unit and a third deletion unit.
[0133] The file acquisition unit is used to acquire the configuration file and obtain the cache survival time from the configuration file.
[0134] The data storage unit is used to store the data to be written into the cache system if the current delayed deletion time is not greater than the preset time, and set the cache survival time to the survival time of the data to be written.
[0135] The third deleting unit is used to delete the data to be written in the cache system when the survival time of the data to be written is not greater than a preset time.
[0136] Preferably, combined Figure 5 According to the content shown, the delayed deletion device also includes: a judgment unit and a third acquisition unit.
[0137] The determination unit is used to determine whether there is cache data corresponding to the data read request in the cache system when receiving the data read request.
[0138] The third acquisition unit is configured to acquire the cache data corresponding to the data read request from the cache system if the cache data corresponding to the data read request exists in the cache system.
[0139] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0140] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0141] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for delayed deletion of data, characterized in that: include: When a data deletion request is received, cache data corresponding to the data deletion request is obtained from the cache system, and a delayed deletion time is obtained from a configuration file; The delayed deletion time is used to indicate the time for delaying deletion of relevant information in the cache system; Extracting key information from the cached data; Generate a cache KEY based on the key information, where the cache KEY is used to identify the corresponding item of the changed data in the database in the cache system; Adding a preset suffix to the cache KEY to obtain a delayed deletion flag, and storing the delayed deletion flag in the cache system; The delayed deletion time is set as the survival time of the delayed deletion flag, where the survival time is used to indicate the validity period of the delayed deletion flag in the cache system; When the survival time is set, the cache data in the cache system is deleted; When a data read request is received, the data to be written is obtained from the database; If the current delayed deletion time is greater than the preset time, the data to be written is stored in the cache system, and the current delayed deletion time is set as the survival time of the data to be written; the current delayed deletion time indicates the remaining survival time of the delayed deletion flag in the cache system; If the survival time of the data to be written is not greater than the preset time, the data to be written and the delayed deletion flag in the cache system are deleted.
2. The method according to claim 1, characterized in that If the current delayed deletion time is greater than the preset time, storing the data to be written into the cache system, and setting the current delayed deletion time to be before the survival time of the data to be written, comprises: Read key information from the data to be written, and generate a cache KEY based on the key information; Adding a preset suffix to the cache KEY to obtain a delayed deletion flag; Read the current delayed deletion time of the delayed deletion flag.
3. The method according to claim 1, characterized in that When receiving a data read request, after obtaining the data to be written from the database, the method further includes: Obtain a configuration file, and obtain a cache survival time from the configuration file; If the current delayed deletion time is not greater than the preset time, the data to be written is stored in the cache system, and the cache survival time is set to the survival time of the data to be written; When the survival time of the data to be written is not greater than the preset time, the data to be written in the cache system is deleted.
4. The method according to claim 1, characterized in that: When receiving a data deletion request, before obtaining cache data corresponding to the data deletion request from the cache system and obtaining the delayed deletion time from the configuration file, the method further includes: When receiving a data read request, determining whether there is cache data corresponding to the data read request in the cache system; If cache data corresponding to the data read request exists in the cache system, the cache data corresponding to the data read request is acquired from the cache system.
5. A device for delayed deletion of data, characterized in that: include: A first acquisition unit, configured to, when receiving a data deletion request, acquire cache data corresponding to the data deletion request from a cache system, and acquire a delayed deletion time from a configuration file; The delayed deletion time is used to indicate the time for delaying deletion of relevant information in the cache system; A generating unit, configured to extract key information from the cache data; Generate a cache KEY based on the key information, where the cache KEY is used to identify the corresponding item of the changed data in the database in the cache system; Adding a preset suffix to the cache KEY to obtain a delayed deletion flag, and storing the delayed deletion flag in the cache system; A setting unit, used for setting the delayed deletion time to the survival time of the delayed deletion flag, wherein the survival time is used for indicating the validity period of the delayed deletion flag in the cache system; A first deleting unit, configured to delete the cache data in the cache system after the survival time is set; A second acquisition unit, configured to acquire the data to be written from the database when receiving a data read request; A storage unit, configured to store the data to be written into the cache system if the current delayed deletion time is greater than a preset time, and set the current delayed deletion time as the survival time of the data to be written; the current delayed deletion time indicates the remaining survival time of the delayed deletion flag in the cache system; The second deleting unit is used to delete the data to be written and the delayed deletion flag in the cache system if the survival time of the data to be written is not greater than the preset time.
6. The device according to claim 5, characterized in that Also includes: An information generating unit, configured to read key information from the data to be written, and generate a cache KEY based on the key information; An adding unit, used for adding a preset suffix to the cache KEY to obtain a delayed deletion flag; A reading unit is used to read the current delayed deletion time of the delayed deletion flag.
7. The device according to claim 5, characterized in that Also includes: A file acquisition unit, used to acquire a configuration file and obtain a cache survival time from the configuration file; A data storage unit, configured to store the data to be written into the cache system if the current delayed deletion time is not greater than a preset time, and to set the cache survival time to the survival time of the data to be written; The third deleting unit is used to delete the data to be written in the cache system when the survival time of the data to be written is not greater than the preset time.
8. The device according to claim 5, characterized in that Also includes: A determination unit, configured to determine, when receiving a data read request, whether there is cache data corresponding to the data read request in the cache system; The third acquisition unit is configured to acquire the cache data corresponding to the data read request from the cache system if the cache data corresponding to the data read request exists in the cache system.