Data processing method, data processing system, storage medium and program product
By generating target keys in the key-value pair database and adding a timed task queue, the memory leakage problem caused by the failure to clean up ThreadLocal objects in time is solved, and the automatic cleaning of thread local variable objects and memory management efficiency is improved.
Patent Information
- Application Number
- CN202411238450.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-27
AI Technical Summary
During the program development process, ThreadLocal object failed to be cleaned in time, resulting in memory leakage.
By generating target keys in the key-value pair database and adding them to the timed task queue, update and delete the expiration time of thread tasks based on the expiration time, ensure that thread local variable objects are automatically cleaned when the task is completed or expired.
It effectively avoids memory leakage, realizes automatic cleaning of ThreadLocal objects, and improves memory management efficiency.
Smart Images

Figure CN119201384A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data processing method, a data processing system, a storage medium, and a computer program product. Background Art
[0002] During program development, variable objects are often used to store local variables of each thread. Each time a variable object is obtained or set, a hash search is required to find the corresponding thread variable copy. If a thread ends but the variable object is not cleaned up, its key-value pair relationship still retains a reference to the variable object. This will cause the variable object to be unable to be garbage collected, thus causing a memory leak. Summary of the invention
[0003] In order to solve one of the above technical problems, the present disclosure provides a data processing method, a data processing system, a storage medium and a computer program product.
[0004] A first aspect of the present disclosure provides a data processing method, which includes: obtaining a thread task and generating a target key corresponding to the thread task in a key-value pair database, wherein the key-value pair database includes a thread local variable object, and the target key corresponds to the thread local variable object in the key-value pair database; adding the target key to a scheduled task queue, and based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key; when the thread task is completed or expires, removing the target key from the scheduled task queue, and deleting the thread local variable object corresponding to the target key.
[0005] In an optional implementation, the thread task is one of a plurality of thread tasks executed synchronously.
[0006] In an optional implementation, before acquiring the thread task, it also includes: creating the thread local variable object, wherein the thread local variable object is used to store local variable information in the key-value pair database.
[0007] In an optional implementation, based on the expiration time of the target key in the scheduled task queue, the expiration time of the thread task corresponding to the target key is updated periodically, including: configuring an update cycle based on the expiration time of the target key; at the beginning of each update cycle, periodically obtaining the remaining expiration time of the target key, and using the remaining expiration time of the target key to update the expiration time of the thread task; and when the remaining expiration time is less than or equal to 0, determining that the thread task is expired.
[0008] In an optional implementation, before generating the target key corresponding to the thread task in the key-value pair database, it also includes: creating a container of the thread local variable object; wherein, generating the target key corresponding to the thread task in the key-value pair database includes: based on the thread task, calling the container of the thread local variable object to generate the target key.
[0009] In an optional implementation, before deleting the thread local variable object corresponding to the target key, it also includes: creating an extension object; wherein, deleting the thread local variable object corresponding to the target key includes: based on the extension object, calling the container of the thread local variable object to delete the thread local variable object according to the target key.
[0010] In an optional implementation manner, an update period for regularly updating the expiration time of the thread task is smaller than the expiration time of the thread task.
[0011] A second aspect of the present disclosure provides a data processing system, which includes a processor and a memory, wherein the memory stores a computer program. When the computer program is executed by the processor, the processor performs the following process: obtaining a thread task, and generating a target key corresponding to the thread task in a key-value pair database, wherein the key-value pair database includes a thread local variable object, and the target key corresponds to the thread local variable object in the key-value pair database; adding the target key to a scheduled task queue, and based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key; when the thread task is completed or expires, removing the target key from the scheduled task queue, and deleting the thread local variable object corresponding to the target key.
[0012] A third aspect of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the data processing method of any embodiment of the present disclosure is executed.
[0013] A fourth aspect of the present disclosure provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the data processing method of any embodiment of the present disclosure is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0015] Figure 1It is a schematic diagram of the process of data processing performed by the data processing system of some embodiments of the present disclosure.
[0016] Figure 2 It is a schematic diagram of the structure of a data processing system of some embodiments of the present disclosure.
[0017] Figure 3 It is a flowchart of a data processing method according to some embodiments of the present disclosure.
[0018] Figure 4 It is a flowchart of a data processing method according to some embodiments of the present disclosure.
[0019] Figure 5 It is a flowchart of a data processing method according to some embodiments of the present disclosure.
[0020] Figure 6 It is a flowchart of a data processing method according to some embodiments of the present disclosure.
[0021] Figure 7 It is a flowchart of a data processing method according to some embodiments of the present disclosure. DETAILED DESCRIPTION
[0022] The present disclosure is further described in detail below in conjunction with the accompanying drawings and implementations. It is understood that the specific implementations described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.
[0023] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0024] Unless otherwise specified, the exemplary embodiments / embodiments shown will be understood as providing exemplary features of various details of some ways in which the technical concept of the present disclosure can be implemented in practice. Therefore, unless otherwise specified, the features of the various embodiments / embodiments can be combined, separated, interchanged and / or rearranged without departing from the technical concept of the present disclosure.
[0025] The use of cross-hatching and / or shading in the accompanying drawings is generally used to make the boundaries between adjacent components clear. As such, unless otherwise specified, the presence or absence of cross-hatching or shading does not convey or indicate any preference or requirement for the specific materials, material properties, dimensions, proportions, commonalities between the components shown, and / or any other characteristics, attributes, properties, etc. of the components. In addition, in the accompanying drawings, the sizes and relative sizes of the components may be exaggerated for clarity and / or descriptive purposes. When the exemplary embodiments can be implemented differently, the specific process sequence can be performed in a different order than described. For example, two successively described processes can be performed substantially simultaneously or in an order opposite to the described order. In addition, the same figure numbers represent the same components.
[0026] When a component is referred to as being "on" or "over," "connected to," or "coupled to" another component, the component may be directly on, directly connected to, or directly coupled to the other component, or intervening components may be present. However, when a component is referred to as being "directly on," "directly connected to," or "directly coupled to" another component, there are no intervening components. For this purpose, the term "connected" may refer to a physical connection, an electrical connection, etc., with or without intervening components.
[0027] The terms used herein are for the purpose of describing specific embodiments, and are not intended to be restrictive. As used herein, unless the context clearly indicates otherwise, the singular forms "one (kind, person)" and "(the)" are also intended to include plural forms. In addition, when the terms "comprise" and / or "include" and their variations are used in this specification, it is explained that there are stated features, integral bodies, steps, operations, parts, assemblies and / or their groups, but one or more other features, integral bodies, steps, operations, parts, assemblies and / or their groups are not excluded from existence or addition. It should also be noted that, as used herein, the terms "substantially", "approximately" and other similar terms are used as approximate terms and not as degree terms, so that they are used to explain the inherent deviations of the measured values, calculated values and / or the values provided that will be recognized by those of ordinary skill in the art.
[0028] During program development, ThreadLocal objects are often used to store local variables of each thread. Each time a ThreadLocal variable is obtained or set, a hash search is required to find the corresponding copy of the thread variable. If a thread ends but the ThreadLocal object is not cleaned up, the key of the corresponding Entry object in ThreadLocalMap still retains a reference to the ThreadLocal object. This will cause the ThreadLocal object to be unable to be garbage collected, resulting in memory leaks.
[0029] Based on the above problems, the present disclosure provides a data processing method and a data processing system. The data processing system may be a computer device including a processor and a memory. Figure 1 A schematic diagram of the process of data processing performed by the data processing system of the embodiment of the present disclosure is shown. The data processing system applies the JDK (Java Development Kit, abbreviated as: JDK) development system to develop programs. During the development of the program, the hash structure of Redis (key-value storage system) of JDK is used to store the local variables of the thread. Since the information of Redis is stored in the memory, when the hash structure of Redis is used to store the local variables of the thread, the multi-thread memory can be used for data processing in the case of concurrent access by multiple threads, and the multi-thread memory can be used to provide the computing resources required for hash search, which has better performance.
[0030] like Figure 1 As shown, the data processing system of the present invention creates a thread local variable object RedisThreadLocal, generates a container RedisThreadLocalProcessor for thread local variable objects, and extends the JDK Runnable object RedisThreadLocalRunnable to store and release Redis local variables.
[0031] Among them, an object refers to an entity that encapsulates data and operations. A local variable object refers to a variable created inside a function or code block. A local variable object exists during the execution of a function or code block and is destroyed after the function or code block is executed.
[0032] Creating a thread local variable object means defining a thread local variable object, including allocating memory space for the thread local variable object to make it a specific instance.
[0033] RedisThreadLocalProcessor is used to generate the key corresponding to redis according to the thread. It is also used to execute the scheduled task of updating the expiration time of the Redis object. It is also used to execute the task of deleting the Redis object.
[0034] RedisThreadLocal is used to store specific local variable information in Redis.
[0035] RedisThreadLocalRunnable is used to automatically call the deletion method of RedisThreadLocal after the thread task is completed, automatically delete the information stored in Redis, and realize automatic cleanup of ThreadLocal objects to avoid memory leaks.
[0036] like Figure 1 As shown in the example, RedisThreadLocalRunnable initiates the task of creating RedisThreadLocal and generates the thread local variable object RedisThreadLocal. The container of the local variable object RedisThreadLocalProcessor generates the corresponding key of Redis according to the task thread. The corresponding key of Redis is put into the queue and used for the scheduled task to update the expiration time of the thread local variable object RedisThreadLocal.
[0037] When the thread task is completed, or when the thread local variable object RedisThreadLocal expires, RedisThreadLocalRunnable initiates the task of deleting RedisThreadLocal, and calls the local variable object container RedisThreadLocalProcessor to execute the deletion method of RedisThreadLocal. Specifically, the local variable object container RedisThreadLocalProcessor removes the key corresponding to Redis from the queue of the scheduled task, and deletes the thread local variable object RedisThreadLocal according to the key corresponding to Redis. In this way, the stored thread local variables can be automatically deleted through the Redis expiration mechanism, realizing automatic cleanup of local variables.
[0038] In summary, the data processing system of the present invention uses the hash structure of Redis to store the local variables of the thread, and automatically deletes the stored local variables of the thread through the expiration mechanism of Redis, thereby avoiding memory leaks caused by storing the local variable information of Redis in the memory.
[0039] Figure 2 The schematic diagram of the structure of the data processing system of the embodiment of the present disclosure is shown. The data processing system 100 includes a processor 10 and a memory 20, and the memory 20 stores a computer program. When the computer program is executed by the processor 10, the processor 10 performs the following process:
[0040] S110: Obtain the thread task and generate a target key corresponding to the thread task in a key-value pair database. The key-value pair database includes a thread local variable object. The target key corresponds to the thread local variable object in the key-value pair database. This process can be executed by a target key generation module.
[0041] S120: adding the target key to the scheduled task queue, and based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key; this process can be executed by the update module.
[0042] S130: When the thread task is executed, or the thread task expires, the target key is removed from the scheduled task queue, and the thread local variable object corresponding to the target key is deleted; this process can be executed by a deletion module.
[0043] The key-value pair database may be a Redis database, and correspondingly, the target key is the key of the Redis database.
[0044] The thread local variable object is a thread local variable object corresponding to the thread task in the key-value pair database. In one example, the thread local variable object can be a thread local variable object RedisThreadLocal of the Redis database. One thread task corresponds to one thread local variable object RedisThreadLocal. The thread local variable object RedisThreadLocal stores specific local variable information in the Redis database. The thread local variable object RedisThreadLocal corresponds to the key of the Redis database.
[0045] A scheduled task queue is a queue that contains one or more thread tasks. The thread tasks in the task queue are executed at a scheduled time. When a target key is added to the scheduled task queue, the target key represents the corresponding thread task.
[0046] The target key in the scheduled task queue is used to update the expiration time of the thread task corresponding to the target key. In an example, the Redis EXPIRE command can be used to update the expiration time of the target key, and the expiration time of the target key is used as the expiration time of the thread task corresponding to the target key.
[0047] When the thread task is completed or expires, there is no need to update the expiration time of the thread task, so the target key corresponding to the thread task can be removed from the scheduled task queue. In addition, when the thread task is completed or expires, the thread local variable object corresponding to the thread task should be deleted to delete the stored thread local variables. Since the thread local variable object corresponding to the thread task corresponds to the target key, the thread local variable object can be determined based on the target key, and the corresponding deletion method can be executed to delete the thread local variable object.
[0048] In summary, the data processing system of the present invention, while using a key-value pair database to store the local variables of the thread, can update the expiration time of the thread task through the expiration time of the target key of the key-value pair database, so that when the thread task expires, the thread local variable object corresponding to the thread task can be automatically deleted in a timely manner, that is, the thread local variable object is deleted, which can avoid memory leaks caused by the inability to recycle the local variable object.
[0049] In an optional embodiment, the thread task is one of multiple thread tasks executed synchronously. That is, the data processing system of the present disclosure can be used for data processing of multi-thread tasks, and supports the use of a key-value database to store thread local variables when multi-thread tasks are accessed concurrently.
[0050] In an optional implementation, before step S110, step S1001 is also included.
[0051] S1001: Create a thread local variable object, where the thread local variable object is used to store local variable information in a key-value pair database.
[0052] In one example, creating a thread local variable object may be creating a thread local variable object RedisThreadLocal. The thread local variable object RedisThreadLocal is used to store local variable information in Redis, and can use memory to store local variable information.
[0053] Among them, local variable information is the data carrier of the local variables of the program function, including, for example, basic data types such as int, float, char, double, etc., and can also be complex data types such as structures, classes, pointers, etc., which are not listed here one by one.
[0054] On the basis of storing the local variable information of the thread task in the thread local variable object, the local variable information stored in the thread local variable object can be deleted when the thread task expires or has been executed. In one example, the thread local variable object (local variable object) is RedisThreadLocal, and the local variable information stored in the thread local variable object RedisThreadLocal is stored in the memory. If the local variable object RedisThreadLocal is not cleaned up at the end of the thread task, the target key corresponding to the local variable object RedisThreadLocal in the key-value database Redis still retains a reference to the local variable object RedisThreadLocal, which will cause the local variable object RedisThreadLocal to be unable to be garbage collected, thereby causing a memory leak. Based on this, the data processing system of the present disclosure automatically deletes the local variable information stored in the thread local variable object (local variable object) at the end of the thread task, so that the thread local variable object is no longer referenced by the target key in the key-value database Redis, avoiding memory leaks.
[0055] In an optional implementation, step S120 includes step S121, step S122 and step S123.
[0056] S121: Based on the expiration time of the target key, configure the update cycle.
[0057] S122: At the beginning of each update cycle, the remaining expiration time of the target key is obtained regularly, and the expiration time of the thread task is updated using the remaining expiration time of the target key.
[0058] S123: When the remaining expiration time is less than or equal to 0, it is determined that the thread task is expired.
[0059] The update cycle refers to the time period for regularly updating the expiration time of the thread task. For example, when the update cycle is 3 seconds, it means that the expiration time of the thread task is updated every 3 seconds. At the beginning of each update cycle, the remaining expiration time of the target key is obtained regularly, that is, at every interval of 3 seconds, the remaining expiration time of the target key is obtained at the beginning of the next update cycle. Updating the expiration time of the thread task using the remaining expiration time of the target key means setting the expiration time of the thread task to the remaining expiration time of the target key.
[0060] If in a certain update cycle, the remaining expiration time of the target key is less than or equal to 0, the thread task corresponding to the target key is determined to be expired.
[0061] In an optional implementation, before step S110, step S1002 is also included.
[0062] S1002: Create a container for thread local variable objects.
[0063] In the above step S110, generating the target key corresponding to the thread task in the key-value pair database includes:
[0064] S111: Based on the thread task, call the container of the thread local variable object to generate a target key.
[0065] In one example, a container for thread local variable objects, namely, a thread local variable object container RedisThreadLocalProcessor is created, and the thread local variable object container RedisThreadLocalProcessor is used to generate a target key corresponding to Redis according to the thread, and to execute a scheduled task of updating the expiration time of the Redis object, and is also used to execute a Redis object deletion task.
[0066] After obtaining the thread task, the key-value pair database Redis creates a local variable object corresponding to the thread task (i.e., the thread local variable object). The container of the thread local variable object generates a key (key) of the key-value pair database Redis according to the thread task, which is called the target key in this article. The target key corresponds to the thread local variable object.
[0067] In an optional implementation, before step S130, step S1003 is also included.
[0068] S1003: Create an extension object.
[0069] In the previous steps, when deleting the thread local variable object corresponding to the target key, it includes:
[0070] Based on the extension object, the container of thread-local variable objects is called to delete the thread-local variable object according to the target key.
[0071] In an example, creating an extension object may be creating a Runnable object RedisThreadLocalRunnable that extends JDK, and the extension object is used to automatically call the deletion method of RedisThreadLocal.
[0072] In an example, the extended Runnable object is created as follows:
[0073] final class RedisThreadLocalRunnable implements Runnable{
[0074]
[0075] According to the above Runnable object creation, the Runnable interface is used to declare the final type member variable runnable; the RedisThreadLocalRunnable constructor is created and accepts a Runnable type parameter runnable; the passed runnable parameter is assigned to the member variable runnable, and the checkNotNull() method of the ObjectUtil tool class is used for non-null judgment; the run() method in the Runnable interface is rewritten; the run() method of the passed runnable object is called in the try block; and the remove() method of RedisThreadLocal is called in the finally block to ensure that the thread-local local variables (that is, the target variables) are cleaned up.
[0076] In an example, the above step S1003 may be executed before step S130, or before step S120, or before step S110, or before step S1002, or before step S1001, and there is no limitation here.
[0077] In an optional implementation, the update period of the timed update of the expiration time of the thread task is smaller than the expiration time of the thread task.
[0078] For example, assuming that the expiration time of the storage information set in the key-value database Redis is 5 seconds, that is, the expiration time of the local variable information stored in the thread local variable object is 5 seconds, which can be expressed as the expiration time of the target key of the database Redis is 5 seconds, and the expiration time of the thread task is consistent with the expiration time of the target key, which is 5 seconds. In this case, the update cycle of the timed update of the expiration time of the thread task is less than 5 seconds, for example, the update cycle is 3 seconds, that is, the expiration time of the thread task is updated every 3 seconds, so that the expiration time of the thread task can be updated in time, ensuring that the local variable information stored in the thread local variable object is deleted in time when the thread task expires.
[0079] Based on the same inventive concept, the embodiment of the present disclosure also provides a data processing method corresponding to the data processing system 100 .
[0080] Figure 3 is a flowchart of a data processing method of some embodiments of the present disclosure. Figure 3 The data processing method M100 provided in the present disclosure may include step S110, step S120 and step S130.
[0081] S110: Obtain a thread task, and generate a target key corresponding to the thread task in a key-value pair database. The key-value pair database includes a thread local variable object, and the target key corresponds to the thread local variable object in the key-value pair database.
[0082] S120: adding the target key to the scheduled task queue, and based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key;
[0083] S130: When the thread task is executed, or the thread task expires, the target key is removed from the scheduled task queue, and the thread local variable object corresponding to the target key is deleted.
[0084] See also Figure 4 In some implementations, the data processing method M100 further includes step S1001.
[0085] S1001: Create a thread local variable object, where the thread local variable object is used to store local variable information in a key-value pair database.
[0086] See also Figure 5 In some implementations, step S120 includes step S121, step S122, and step S123.
[0087] S121: Based on the expiration time of the target key, configure the update cycle;
[0088] S122: At the beginning of each update cycle, the remaining expiration time of the target key is obtained regularly, and the expiration time of the thread task is updated using the remaining expiration time of the target key; and
[0089] S123: When the remaining expiration time is less than or equal to 0, it is determined that the thread task is expired.
[0090] See also Figure 6 In some implementations, the data processing method M100 also includes step S1002.
[0091] S1002: Create a container for thread local variable objects.
[0092] Among them, step S1002 can be executed before step S1001, or after step S1001 and before step S110, and there is no limitation here.
[0093] exist Figure 6 In the illustrated process, step S110 may include step S111.
[0094] S111: Based on the thread task, call the container of the thread local variable object to generate a target key.
[0095] See also Figure 7 In some implementations, the data processing method M100 further includes step S1003.
[0096] S1003: Create an extension object.
[0097] exist Figure 7 In the illustrated process, step S130 also includes step S131.
[0098] S131: Based on the extended object, the container of the thread local variable object is called to delete the thread local variable object according to the target key.
[0099] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.
[0100] The computer program or instructions may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0101] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0102] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0103] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0104] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0105] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.
[0106] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0107] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A data processing method, characterized in that: include: Obtaining a thread task, and generating a target key corresponding to the thread task in a key-value pair database, wherein the key-value pair database includes a thread local variable object, and the target key corresponds to the thread local variable object in the key-value pair database; Adding the target key to a scheduled task queue, and based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key; as well as When the thread task is executed and completed, or when the thread task expires, the target key is removed from the scheduled task queue, and the thread local variable object corresponding to the target key is deleted.
2. The data processing method according to claim 1, characterized in that: Before obtaining the thread task, it also includes: The thread local variable object is created, and the thread local variable object is used to store local variable information in the key-value pair database.
3. The data processing method according to claim 1, characterized in that: Based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key includes: Based on the expiration time of the target key, configure the update period; At the beginning of each update cycle, the remaining expiration time of the target key is obtained regularly, and the expiration time of the thread task is updated using the remaining expiration time of the target key; and When the remaining expiration time is less than or equal to 0, it is determined that the thread task is expired.
4. The data processing method according to claim 1, characterized in that: Before generating the target key corresponding to the thread task in the key-value pair database, the method further includes: Creating a container for the thread local variable object; Wherein, generating the target key corresponding to the thread task in the key-value pair database includes: Based on the thread task, the container of the thread local variable object is called to generate the target key.
5. The data processing method according to claim 4, characterized in that: Before deleting the thread local variable object corresponding to the target key, the method further includes: Create an extension object; Wherein, deleting the thread local variable object corresponding to the target key includes: Based on the extension object, the container of the thread local variable object is called to delete the thread local variable object according to the target key.
6. The data processing method according to claim 1, characterized in that: An update period for regularly updating the expiration time of the thread task is less than the expiration time of the thread task.
7. The data processing method according to claim 1, characterized in that: The thread task is one of a plurality of thread tasks executed synchronously.
8. A data processing system, characterized in that: The invention comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following process: Obtaining a thread task, and generating a target key corresponding to the thread task in a key-value pair database, wherein the key-value pair database includes a thread local variable object, and the target key corresponds to the thread local variable object in the key-value pair database; Adding the target key to a scheduled task queue, and based on the expiration time of the target key in the scheduled task queue, regularly updating the expiration time of the thread task corresponding to the target key; as well as When the thread task is executed and completed, or when the thread task expires, the target key is removed from the scheduled task queue, and the thread local variable object corresponding to the target key is deleted.
9. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, it is used to implement the method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises a computer program, which is used to implement at least the method according to any one of claims 1 to 7 when executed by a processor.