feat 服务增加清理缓存

This commit is contained in:
jxxghp 2023-10-31 10:32:56 +08:00
parent 87eae72f51
commit 0d3dfdcbda
2 changed files with 17 additions and 4 deletions

View File

@ -219,8 +219,5 @@ def execute_command(jobid: str,
"""
if not jobid:
return schemas.Response(success=False, message="命令不能为空!")
if jobid == "subscribe_search":
Scheduler().start(jobid, state='R')
else:
Scheduler().start(jobid)
return schemas.Response(success=True)

View File

@ -71,6 +71,10 @@ class Scheduler(metaclass=Singleton):
"transfer": {
"func": TransferChain().process,
"running": False,
},
"clear_cache": {
"func": SchedulerChain().clear_cache,
"running": False,
}
}
@ -202,6 +206,18 @@ class Scheduler(metaclass=Singleton):
minutes=10
)
# 缓存清理服务每隔24小时
self._scheduler.add_job(
self.start,
"interval",
id="clear_cache",
name="缓存清理",
hours=24,
kwargs={
'job_id': 'clear_cache'
}
)
# 打印服务
logger.debug(self._scheduler.print_jobs())