A method and apparatus for scheduling a timing task

CN116382869BActive Publication Date: 2026-09-18BEIJING SIMULATION CENT
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310316136.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2026-09-18
Estimated Expiration
2043-03-28

AI Technical Summary

Technical Problem

[0003]实现任务有很多种方式,要确保自身的轻量级,在不使用第三方框架的情况下,传统的定时器无法动态的添加或者删除任务

Benefits of technology

本发明创造的技术是要解决不依赖第三方框架的情况下,无法动态的设定任务执行的问题。本发明能够删除已经存在的任务,并且在缓存中只存放两个小时内需要执行的任务。整个调度中心中26小时内任务则由redis(缓存式数据库)存储,长时间后执行的任务由Oracle(数据库)保存,Oracle身为根数据库,会存储非直接发送的所有任务,直到每晚12点检测发现超过提醒时间26小时后被清除。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116382869B_ABST
    Figure CN116382869B_ABST
Patent Text Reader

Abstract

The application discloses a kind of timing task scheduling method and equipment, the method includes: deploying task scheduling system, the task scheduling system includes scheduling center, cache, database and cache type database;According to classification algorithm, the task of newly built is respectively stored in scheduling center, cache, database or cache type database;Scheduling center obtains the data of task in cache, cache type database or database according to acquisition rule, configures execution thread for each task, executes task by the execution thread, and forwards the task to user.The application can delete the task that has existed, and only store the task that needs to be executed within two hours in cache;It also provides timing task query interface to the outside, and can delete the timing task that has existed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology. More specifically, it relates to a method and apparatus for scheduling timed tasks. Background Technology

[0002] With the widespread application and development of computers, tasks, as a system scheduling tool, are widely used in some systems that require scheduled tasks, such as collecting data at certain points in time or performing certain actions at some future time.

[0003] There are many ways to accomplish tasks. To ensure lightweight operation without using third-party frameworks, traditional timers cannot dynamically add or delete tasks. Developers must set specific execution intervals or times during development, which clearly cannot meet the needs of dynamic management of scheduled task execution.

[0004] Therefore, there is a need to provide a task scheduling method, device, and storage medium. Summary of the Invention

[0005] One object of the present invention is to provide a method and apparatus for scheduling timed tasks.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: The first aspect of this invention provides a method for scheduling timed tasks, comprising: Deploy a task scheduling system, which includes a scheduling center, a cache, a database, and a cached database; Based on the classification algorithm, newly created tasks are stored in the scheduling center, cache, database, or cached database, respectively. The scheduling center retrieves task data from the cache, cached database, or database according to the acquisition rules, configures an execution thread for each task, executes the task through the execution thread, and forwards the task to the user.

[0007] Optionally, the method further includes: When using the aforementioned scheduling system, Clear all task configurations and execution threads in the scheduling center, and initialize the scheduling center; Set the cached data to refresh once every set interval; At 0:00 every day, the cached database is refreshed. Specifically, the data within the second set time period in the current database is loaded into the cached database's expired ordered set within the third set time period, and the dirty data in the previous second set time period in the current database is cleared. The first set duration, the second set duration, and the third set duration are in the hour range, and the second set duration is longer than the third set duration, and the third set duration is longer than the first set duration.

[0008] Optionally, the method further includes: When adding a task, the added task is stored in the scheduling center, cache, database, or cached database according to the classification algorithm.

[0009] Optionally, the acquisition rules include: Retrieve task data for all executing threads at the current second of the task's execution from the cached database for the current day; If there is a task but the task data is not retrieved from the cached database, it will be retrieved from the database as compensation. If no task data is retrieved from the database, then the task and its record information in the scheduling center and cache are cleared.

[0010] Optionally, the acquisition rules further include: Retrieve task data from the current time to the fourth set time period from the current time in the cache database and store it in the cache, then compare it with the tasks currently running in the scheduling center; If the acquired task is available in the scheduling center, skip it; If not, a new task will be added and loaded into the scheduling center; The fourth set duration is in the hour range, and is less than the third set duration but greater than the first set duration.

[0011] Optionally, storing tasks in a scheduling center, cache, database, or cached database according to the classification algorithm includes: When creating a task, based on the task execution time, Load tasks whose execution time is less than the fifth set duration into the scheduling center; Tasks whose execution time is greater than the fifth set duration and less than the fourth set duration for reading from the cached database are loaded into the scheduling center, cache, cached database, and database. Tasks whose execution time is greater than the time interval for reading from the cached database (the fourth set time interval) and less than the time interval for refreshing the cached database (the third set time interval) are loaded into the cached database and the database. Load tasks whose execution time exceeds the third set time for refreshing the cached database into the database; The fifth setting is a duration in minutes.

[0012] Optionally, when adding tasks, the method stores the tasks in a scheduling center, cache, database, or cached database according to a classification algorithm, including: Load tasks whose execution time is less than the fifth set duration into the scheduling center; Tasks whose execution time is greater than the fifth set duration and less than the fourth set duration for reading from the cached database are loaded into the scheduling center, cache, cached database, and database. Tasks whose execution time is greater than the time interval for reading from the cached database (the fourth set time interval) and less than the time interval for refreshing the cached database (the third set time interval) are loaded into the cached database and the database. Load tasks whose execution time exceeds the third set time for refreshing the cached database into the database; The fifth setting is a duration in minutes.

[0013] Optionally, the method further includes, when adding a task: The added task data is set to expire in the cached database for the sixth time interval in hours.

[0014] Optionally, the method further includes: When deleting a task, check if the task to be deleted has other tasks to execute in other threads of the scheduling center at the time of its execution. If not, delete the data for the tasks mentioned in the scheduling center, cache, cached database, and database. If present, delete the cached database and the data for the tasks of the execution thread described in the database.

[0015] A second aspect of the present invention provides a timed task scheduling device, comprising: The deployment module is used to deploy a task scheduling system, which includes a scheduling center, a cache, a database, and a cached database. The scheduling center is used to obtain data of tasks in the cache, cached database or database according to the acquisition rules, and is also used to configure an execution thread for each task. The classification module is used to store newly created tasks into the scheduling center, cache, database, or cached database according to the classification algorithm. The task forwarding module is used to forward tasks executed in the scheduling center to users; The task deletion module is used to query whether the execution time of the task to be deleted is in another thread in the scheduling center. If not, the data of the task in the scheduling center, cache, cached database and database is deleted. If so, the data of the task in the cached database and the execution thread in the database is deleted.

[0016] A third aspect of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method provided in the first aspect of the present invention.

[0017] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method provided in the first aspect of the present invention.

[0018] The beneficial effects of this invention are as follows: This invention aims to solve the problem of dynamically setting task execution without relying on a third-party framework. The invention can delete existing tasks and only store tasks to be executed within the next two hours in the cache. Tasks within the entire scheduling center for the next 26 hours are stored in Redis (a cached database), while tasks to be executed after a longer period are stored in Oracle (a database). Oracle, as the root database, stores all tasks not directly sent until it detects that the task has exceeded the 26-hour warning time at midnight each night and then clears it. Attached Figure Description

[0019] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0020] Figure 1 A flowchart of the method described in this invention is shown. Detailed Implementation

[0021] To more clearly illustrate the present invention, the following description is in conjunction with preferred embodiments and accompanying drawings. Figure 1 The present invention will be further described below. Similar components in the accompanying drawings are indicated by the same reference numerals. Those skilled in the art should understand that the following detailed description is illustrative rather than restrictive and should not be construed as limiting the scope of protection of the present invention.

[0022] A scheduled task method, comprising: Deploy a task scheduling system, which includes a scheduling center, a cache, a database, and a cached database; Based on the classification algorithm, newly created tasks are stored in the scheduling center, cache, database, or cached database, respectively. The scheduling center retrieves task data from the cache, cached database, or database according to the acquisition rules, configures an execution thread for each task, executes the task through the execution thread, and forwards the task to the user.

[0023] Optionally, the method further includes: When using the aforementioned scheduling system, Clear all task configurations and execution threads in the scheduling center, and initialize the scheduling center; Set the cached data to refresh once every hour. At 0:00 every day, the cached database is refreshed. Specifically, the data within the second set time period (26 hours) of the current time in the database is loaded into the invalid ordered set of the third set time period (24 hours) of the cached database, and the dirty data in the previous second set time period (26 hours) in the current time database is cleared. The first set duration, the second set duration, and the third set duration are in the hour range, and the second set duration is longer than the third set duration, and the third set duration is longer than the first set duration.

[0024] Optionally, the method further includes: When adding a task, the added task is stored in the scheduling center, cache, database, or cached database according to the classification algorithm.

[0025] Optionally, the acquisition rules include: Retrieve task data for all executing threads at the current second of the task's execution from the cached database for the current day; If there is a task but the task data is not retrieved from the cached database, it will be retrieved from the database as compensation. If no task data is retrieved from the database, then the task and its record information in the scheduling center and cache are cleared.

[0026] Optionally, the acquisition rules further include: Retrieve task data from the current time to the fourth set time period (2 hours) from the current time in the cache database and store it in the cache, then compare it with the tasks currently running in the scheduling center; If the acquired task is available in the scheduling center, skip it; If not, a new task will be added and loaded into the scheduling center; The fourth set duration (2 hours) is in the hour range and is less than the third set duration (24 hours) and greater than the first set duration (1 hour).

[0027] Optionally, storing tasks in a scheduling center, cache, database, or cached database according to the classification algorithm includes: When creating a task, based on the task execution time, Tasks with an execution time less than the fifth set duration (5 minutes) will be loaded into the scheduling center; Tasks whose execution time is greater than the fifth set duration (5 minutes) and less than the fourth set duration (2 hours) for reading the cached database are loaded into the scheduling center, cache, cached database, and database. Tasks whose execution time is greater than the fourth set time interval (2 hours) for reading from the cached database and less than the third set time interval (24 hours) for refreshing the cached database are loaded into the cached database and the database. Load tasks whose execution time exceeds the third set time (24 hours) for refreshing the cached database into the database; The fifth set duration (5 minutes) is in minutes.

[0028] Optionally, when adding tasks, the method stores the tasks in a scheduling center, cache, database, or cached database according to a classification algorithm, including: Tasks with an execution time less than the fifth set duration (5 minutes) will be loaded into the scheduling center; Tasks whose execution time is greater than the fifth set duration (5 minutes) and less than the fourth set duration (2 hours) for reading the cached database are loaded into the scheduling center, cache, cached database, and database. Tasks whose execution time is greater than the fourth set time interval (2 hours) for reading from the cached database and less than the third set time interval (24 hours) for refreshing the cached database are loaded into the cached database and the database. Load tasks whose execution time exceeds the third set time (24 hours) for refreshing the cached database into the database; The fifth set duration (5 minutes) is in minutes.

[0029] Optionally, the method further includes, when adding a task: Set the expiration time of added task data in the cached database to the sixth set duration in hours (24 hours).

[0030] Optionally, the method further includes: When deleting a task, check if the task to be deleted has other tasks to execute in other threads of the scheduling center at the time of its execution. If not, delete the data for the tasks mentioned in the scheduling center, cache, cached database, and database. If present, delete the cached database and the data for the tasks of the execution thread described in the database.

[0031] A timed task scheduling device, comprising: The deployment module is used to deploy a task scheduling system, which includes a scheduling center, a cache, a database, and a cached database. The scheduling center is used to obtain data of tasks in the cache, cached database or database according to the acquisition rules, and is also used to configure an execution thread for each task. The classification module is used to store newly created tasks into the scheduling center, cache, database, or cached database according to the classification algorithm. The task forwarding module is used to forward tasks executed in the scheduling center to users; The task deletion module is used to query whether the execution time of the task to be deleted is in another thread in the scheduling center. If not, the data of the task in the scheduling center, cache, cached database and database is deleted. If so, the data of the task in the cached database and the execution thread in the database is deleted.

[0032] Specifically, according to this embodiment, the process described in the flowchart above can be implemented as a computer software program. For example, this embodiment includes a computer program product comprising a computer program tangibly embodied on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium.

[0033] In one specific embodiment, the method described in this invention can be implemented as a computer software program.

[0034] The scheduled execution function uses dynamic tasks, and the doTask(DatereminderTime) method is executed at a specified time in the scheduling center.

[0035] The ScheduleTask class implements the ScheduleConfigurer class and overrides its configureTasks method. This method is executed when Spring Boot starts. The method first calls the refreshRedis() method in the RedisTask class to refresh the Redis cache information, and then creates a task that runs once every hour. This task executes the refresh() method.

[0036] refresh() retrieves task data from the current time up to 2 hours later from Redis and compares it with the tasks in the scheduling center. If the execution time of the retrieved task is already in the scheduling center, it is skipped; otherwise, the task is added to the scheduling center.

[0037] The doTask(Date reminderTime) method retrieves all task data for the current second of the task execution time from the Redis cache for that day. If there is a task but the data is not available in Redis, it will be retrieved from the database. If the data is not available in the database, the task and its record will be cleared from the scheduling center and the futureMap.

[0038] If there is data, call send(List) <timedtaskmessage>The `taskMessages(Boolean isSend)` method sends messages. Messages entered through the `doTask` method are all tasks whose execution time is more than five minutes from the current time. Therefore, it clears the Oracle running scheduler records. For tasks in the scheduler whose execution time is less than five minutes from the current time, messages are sent directly.

[0039] When creating a task, tasks with execution times less than five minutes are executed directly. Tasks with execution times greater than five minutes from the current time but less than two hours from the current time are loaded into the scheduling center, stored in a record set, loaded into Redis, and then stored in the database. Tasks with execution times greater than two hours from the current time but less than one day from the current time are loaded into Redis and then stored in the database. Tasks with execution times greater than one day from the current time are directly stored in the database.

[0040] The refreshRedisTask() method in RedisTask is called at 0:00 every day. This method loads the data from the database up to the last 26 hours into a 24-hour expired Redis sorted set and removes dirty data older than 26 hours.

[0041] addTask(List <timedtaskmessagedto>The `taskDtoList` method adds tasks. Each time a task is added, `deleteTask(String eventId)` is called to clear all tasks under that delegate, and then `isSend(List<Task>)` is called. <timedtaskmessagedto>`taskDtoList` first initializes the task data. Then, based on the task execution time, alerts for tasks whose execution time is less than five minutes from the current time are sent directly; tasks whose execution time is more than five minutes but less than the database loading time interval of 2 hours are loaded into the scheduling center, stored in a record set, loaded into Redis, and then stored in the database; tasks whose execution time is more than 2 hours but less than the cache refresh time interval of 1 day are loaded into Redis and then stored in the database; tasks whose execution time is more than 1 day is directly stored in the database. Finally, if no expiration time is set in Redis, it is set to 1 day.

[0042] The `deleteTask(String eventId)` method deletes tasks associated with a given agent based on the agent's ID. This method first retrieves all tasks under the given agent, then checks if there are any other tasks under other agents that need to be executed at the current time. If not, it deletes the task, record, and event information for that schedule in the scheduling center, Redis, and Oracle. If so, it only deletes the task information for that agent in Redis and Oracle.

[0043] The `listTaskMessage(String eventId)` method retrieves task information under a proxy based on the proxy ID.

[0044] In this invention, task information is cached in Redis and stored as a zSet. Redis database is memory-based and has a much faster query efficiency compared to relational databases.

[0045] Due to the time-sensitive nature of current task delivery requirements, Redis can respond more quickly with large data volumes, ensuring real-time task execution. Secondly, this invention uses an algorithm to categorize and store tasks when they are added, storing tasks that will be executed much later in the database instead of directly loading them into the scheduling center, significantly reducing server load. Developers can customize the timing settings to suit their business scenarios. Furthermore, the program periodically cleans up potentially dirty data and provides leeway when loading into the cache or scheduling center to ensure data reliability; therefore, this issue needs to be considered if custom timing settings are used. Tasks already loaded into the scheduling center are supported by both Redis and Oracle.

[0046] Take creating a schedule reminder task in a smart calendar as an example.

[0047] Create a new entity class `TimedTaskMessage` to record the task. This class must have a cron expression storage field. In this case, it's a smart calendar, so it also needs a schedule ID field, a reminder time field, an advance reminder type field (1. now; 2. 5 minutes in advance; 3. 10 minutes in advance; 4. 30 minutes in advance; 5. 1 hour in advance; 6. 2 hours in advance; 7. 1 day in advance;), and a recipient field. The cron expression field is converted from the reminder time. Then, create the corresponding Oracle table and mapping mapper for this entity.

[0048] Create a `RedisTask` class, declaring `private final double redisScoreKey = 100000000` and `private TimedTaskMessageMapper taskMapper`. Write a `refreshRedis()` method, which clears dirty data older than 26 hours and loads tasks from the current 26 hours into Redis. Redis uses a sorted set (zSet), where the `score` value is the timestamp of the reminder time minus `redisScoreKey`, and the expiration time of `redisKey` is set to 1 day. Set the `refreshRedisTask()` task to be executed every night at midnight, calling the `refreshRedis()` method.

[0049] Create a ScheduleTask class, implement ScheduleConfigurer, and inject the corresponding mapper for the entity. Declaration. private final double redisScoreKey = 100000000, ConcurrentHashMap <String, ScheduledFuture<?> `futureMap = new ConcurrentHashMap<>()` (used to store records of tasks running in the scheduling center), `private ThreadPoolTaskScheduler` (task thread pool), `private RedisTask` (redisTask).

[0050] Next, configure the thread pool. As needed, set the number of threads in the `ThreadPoolTaskScheduler` using `@Bean` and then inject the configuration into the declared `ThreadPoolTaskScheduler`. Override the `configureTasks(ScheduledTaskRegistrar taskRegistrar)` method. First, call `refreshRedis` in `RedisTask` to flush the tasks to the Redis cache. Then, add a task to execute the newly added tasks from the scheduling center, with a timer interval of one hour, executed using the `refresh` method.

[0051] The `refresh()` method returns a `Runnable`. The `run()` method is overridden. First, it checks if the key exists in Redis. If not, it calls `refreshRedis()` in `RedisTask` to flush the task to the Redis cache. If the key exists, it retrieves tasks from the current time within the last two hours. If the retrieved task is not empty, and the `futureMap` in the scheduling center is empty, it creates a new task and adds it to the scheduling center. Otherwise, it checks if the task exists in the `futureMap`; if not, it creates a new task and adds it to the scheduling center. The first parameter for creating the task is `doTask(Date reminderTime)`, and the second is `new CronTrigger(String expression)` (where `expression` is the cron expression for the reminder time).

[0052] The `doTask(Date reminderTime)` method is the business logic execution method. It retrieves all tasks within one second (within the specified second) from the Redis key storing today's data, based on the previously stored `score` values. If the retrieved tasks are not empty, it calls `send(List)`. <timedtaskmessage>The `taskMessages` and `BooleanisSend` methods send reminders. If the message is empty, data is retrieved from Oracle as compensation. If no data exists at that point in time, the task is removed from the scheduling center.

[0053] send(List <timedtaskmessage>The `taskMessages(Boolean isSend)` method sends reminders. The first parameter is a collection of reminders, and the second parameter determines whether the reminder time was less than 5 minutes when the task was created. First, a message is sent. If `isSend` is false, it means the time is greater than five minutes, and corresponding records exist in Oracle, Redis, and the scheduling center, requiring removal.

[0054] addTask(List <timedtaskmessagedto>The `taskDtoList` method adds reminders. Each time a reminder is added, it calls `deleteTask(String eventId)` to clear all reminders for that schedule, and then calls `isSend(List<EventId>)`. <timedtaskmessagedto>The `taskDtoList` method then returns the `isSend` method, which returns the list of data to be added to the database. <timedtaskmessage>Store it in Oracle in addTask.

[0055] isSend(List <timedtaskmessagedto>The `taskDtoList` method first initializes the reminder data. In the `isSend` method, it further determines the reminder time based on the following: reminders less than five minutes in advance are sent directly; reminders greater than five minutes but less than the database loading time interval of 2 hours are loaded into the scheduling center, stored in a record set, loaded into Redis, and then stored in the database; reminders greater than the database loading time interval of 2 hours but less than the cache refresh time interval of 1 day are loaded into Redis and then stored in the database; reminders greater than the cache refresh time interval of 1 day are directly stored in the database. Finally, if no expiration time is set in Redis, it is set to 1 day.

[0056] The `deleteTask(String eventId)` method deletes reminders related to a given schedule. It first retrieves all reminders for that schedule, then checks if there are other schedules requiring reminders at that time. If not, it deletes the task, record, and reminder information for that schedule from the scheduling center, Redis, and Oracle. Note that when comparing data points in Redis, comparing the schedule ID is crucial to avoid accidentally deleting tasks for other schedules at that time. If so, only the reminder information for that schedule in Redis and Oracle will be deleted.

[0057] The `listTaskMessage(String eventId)` method retrieves the messageType of reminders under a given schedule. If other information is needed, the returned data can be modified accordingly.

[0058] In the description of this invention, it should be noted that the terms "upper," "lower," etc., indicating the orientation or positional relationship are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Unless otherwise expressly specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication between two components. For those skilled in the art, the specific meaning of the above terms in this invention can be understood according to the specific circumstances.

[0059] It should also be noted that in the description of this invention, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention and are not intended to limit the implementation of the present invention. For those skilled in the art, other variations or modifications can be made based on the above description. It is impossible to exhaustively list all embodiments here, and all obvious variations or modifications derived from the technical solutions of the present invention are still within the protection scope of the present invention.< / timedtaskmessagedto> < / timedtaskmessage> < / timedtaskmessagedto> < / timedtaskmessagedto> < / timedtaskmessage> < / timedtaskmessage> < / timedtaskmessagedto> < / timedtaskmessagedto> < / timedtaskmessage>

Claims

1. A method for scheduling timed tasks, characterized in that, include: Deploy a task scheduling system, which includes a scheduling center, a cache, a database, and a cached database; Based on the classification algorithm, newly created tasks are stored in the scheduling center, cache, database, or cached database, respectively. The scheduling center retrieves task data from the cache, cached database, or database according to the acquisition rules, configures an execution thread for each task, executes the task through the execution thread, and forwards the task to the user. The method also includes: When using the aforementioned scheduling system, Clear all task configurations and execution threads in the scheduling center, and initialize the scheduling center; Set the cached data to refresh once every set interval; At 0:00 every day, the cached database is refreshed. Specifically, the data within the second set time period in the current database is loaded into the cached database's expired ordered set within the third set time period, and the dirty data in the previous second set time period in the current database is cleared. The first set duration, the second set duration, and the third set duration are in the hour range, and the second set duration is longer than the third set duration, and the third set duration is longer than the first set duration; The acquisition rules include: Retrieve task data for all executing threads at the current second of the task's execution from the cached database for the current day; If there is a task but the task data is not retrieved from the cached database, it will be retrieved from the database as compensation. If no task data is retrieved from the database, then the task and its record information in the scheduling center and cache are cleared.

2. The method as described in claim 1, characterized in that, The method also includes: When adding a task, the added task is stored in the scheduling center, cache, database, or cached database according to the classification algorithm.

3. The method as described in claim 1, characterized in that, The acquisition rules also include: Retrieve task data from the current time to the fourth set time period from the current time in the cache database and store it in the cache, then compare it with the tasks currently running in the scheduling center; If the acquired task is available in the scheduling center, skip it; If not, a new task will be added and loaded into the scheduling center; The fourth set duration is in the hour range, and is less than the third set duration but greater than the first set duration.

4. The method as described in claim 1, characterized in that, The step of storing tasks in a scheduling center, cache, database, or cached database according to a classification algorithm includes: When creating a task, based on the task execution time, Load tasks whose execution time is less than the fifth set duration into the scheduling center; Tasks whose execution time is greater than the fifth set duration and less than the fourth set duration for reading from the cached database are loaded into the scheduling center, cache, cached database, and database. Tasks whose execution time is greater than the time interval for reading from the cached database (the fourth set time interval) and less than the time interval for refreshing the cached database (the third set time interval) are loaded into the cached database and the database. Load tasks whose execution time exceeds the third set time for refreshing the cached database into the database; The fifth setting is a duration in minutes.

5. The method as described in claim 2, characterized in that, The method, when adding tasks, stores tasks in a scheduling center, cache, database, or cached database according to a classification algorithm, including: Load tasks whose execution time is less than the fifth set duration into the scheduling center; Tasks whose execution time is greater than the fifth set duration and less than the fourth set duration for reading from the cached database are loaded into the scheduling center, cache, cached database, and database. Tasks whose execution time is greater than the time interval for reading from the cached database (the fourth set time interval) and less than the time interval for refreshing the cached database (the third set time interval) are loaded into the cached database and the database. Load tasks whose execution time exceeds the third set time for refreshing the cached database into the database; The fifth setting is a duration in minutes.

6. The method as described in claim 1, characterized in that, The method further includes the following when adding a task: The added task data is set to expire in the cached database for the sixth time interval in hours.

7. The method as described in claim 1, characterized in that, The method further includes: When deleting a task, check if the task to be deleted has other tasks to execute in other threads of the scheduling center at the time of its execution. If not, delete the data for the tasks mentioned in the scheduling center, cache, cached database, and database. If present, delete the cached database and the data for the tasks of the execution thread described in the database.

8. A timed task scheduling device based on the method of any one of claims 1 to 7, characterized in that, include: The deployment module is used to deploy a task scheduling system, which includes a scheduling center, a cache, a database, and a cached database. The scheduling center is used to obtain data of tasks in the cache, cached database or database according to the acquisition rules, and is also used to configure an execution thread for each task. The classification module is used to store newly created tasks into the scheduling center, cache, database, or cached database according to the classification algorithm. The task forwarding module is used to forward tasks executed in the scheduling center to users; The task deletion module is used to query whether the execution time of the task to be deleted is in another thread in the scheduling center. If not, the data of the task in the scheduling center, cache, cached database and database is deleted. If so, the data of the task in the cached database and the execution thread in the database is deleted.

Citation Information

Patent Citations

  • Timing task processing method and device, equipment and storage medium

    CN114416316A

  • Delay task processing method and device, computer equipment and storage medium

    CN115202837A