feat 新增清理TMDB缓存命令
This commit is contained in:
parent
afe5ee9abb
commit
7435b7c702
@ -406,3 +406,9 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
定时任务,每10分钟调用一次,模块实现该接口以实现定时服务
|
定时任务,每10分钟调用一次,模块实现该接口以实现定时服务
|
||||||
"""
|
"""
|
||||||
return self.run_module("scheduler_job")
|
return self.run_module("scheduler_job")
|
||||||
|
|
||||||
|
def clear_cache(self) -> None:
|
||||||
|
"""
|
||||||
|
清理缓存,模块实现该接口响应清理缓存事件
|
||||||
|
"""
|
||||||
|
return self.run_module("clear_cache")
|
||||||
|
17
app/chain/system.py
Normal file
17
app/chain/system.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from typing import Union
|
||||||
|
|
||||||
|
from app.chain import ChainBase
|
||||||
|
from app.schemas import Notification, MessageChannel
|
||||||
|
|
||||||
|
|
||||||
|
class SystemChain(ChainBase):
|
||||||
|
"""
|
||||||
|
系统级处理链
|
||||||
|
"""
|
||||||
|
def remote_clear_cache(self, channel: MessageChannel, userid: Union[int, str]):
|
||||||
|
"""
|
||||||
|
清理系统缓存
|
||||||
|
"""
|
||||||
|
self.clear_cache()
|
||||||
|
self.post_message(Notification(channel=channel,
|
||||||
|
title=f"缓存清理完成!", userid=userid))
|
@ -8,6 +8,7 @@ from app.chain.download import DownloadChain
|
|||||||
from app.chain.mediaserver import MediaServerChain
|
from app.chain.mediaserver import MediaServerChain
|
||||||
from app.chain.site import SiteChain
|
from app.chain.site import SiteChain
|
||||||
from app.chain.subscribe import SubscribeChain
|
from app.chain.subscribe import SubscribeChain
|
||||||
|
from app.chain.system import SystemChain
|
||||||
from app.chain.transfer import TransferChain
|
from app.chain.transfer import TransferChain
|
||||||
from app.core.event import Event as ManagerEvent
|
from app.core.event import Event as ManagerEvent
|
||||||
from app.core.event import eventmanager, EventManager
|
from app.core.event import eventmanager, EventManager
|
||||||
@ -45,6 +46,8 @@ class Command(metaclass=Singleton):
|
|||||||
self.eventmanager = EventManager()
|
self.eventmanager = EventManager()
|
||||||
# 插件管理器
|
# 插件管理器
|
||||||
self.pluginmanager = PluginManager()
|
self.pluginmanager = PluginManager()
|
||||||
|
# 处理链
|
||||||
|
self.chain = CommandChian(self._db)
|
||||||
# 内置命令
|
# 内置命令
|
||||||
self._commands = {
|
self._commands = {
|
||||||
"/cookiecloud": {
|
"/cookiecloud": {
|
||||||
@ -111,6 +114,11 @@ class Command(metaclass=Singleton):
|
|||||||
"func": TransferChain(self._db).remote_transfer,
|
"func": TransferChain(self._db).remote_transfer,
|
||||||
"description": "手动整理",
|
"description": "手动整理",
|
||||||
"data": {}
|
"data": {}
|
||||||
|
},
|
||||||
|
"/clear_cache": {
|
||||||
|
"func": SystemChain(self._db).remote_clear_cache,
|
||||||
|
"description": "清理缓存",
|
||||||
|
"data": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# 汇总插件命令
|
# 汇总插件命令
|
||||||
@ -125,8 +133,6 @@ class Command(metaclass=Singleton):
|
|||||||
'data': command.get('data')
|
'data': command.get('data')
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# 处理链
|
|
||||||
self.chain = CommandChian(self._db)
|
|
||||||
# 广播注册命令菜单
|
# 广播注册命令菜单
|
||||||
self.chain.register_commands(commands=self.get_commands())
|
self.chain.register_commands(commands=self.get_commands())
|
||||||
# 消息处理线程
|
# 消息处理线程
|
||||||
|
@ -389,3 +389,10 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
:param page: 页码
|
:param page: 页码
|
||||||
"""
|
"""
|
||||||
return self.tmdb.get_person_credits(person_id=person_id, page=page)
|
return self.tmdb.get_person_credits(person_id=person_id, page=page)
|
||||||
|
|
||||||
|
def clear_cache(self):
|
||||||
|
"""
|
||||||
|
清除缓存
|
||||||
|
"""
|
||||||
|
self.tmdb.clear_cache()
|
||||||
|
self.cache.clear()
|
||||||
|
@ -1124,3 +1124,9 @@ class TmdbHelper:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def clear_cache(self):
|
||||||
|
"""
|
||||||
|
清除缓存
|
||||||
|
"""
|
||||||
|
self.tmdb.cache_clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user