✨feat(core): 优化数据库调用表现 (#2089)

This commit is contained in:
ManyManyTomato
2026-02-01 14:28:51 +08:00
committed by GitHub
parent 7890b39002
commit 203754e300
10 changed files with 341 additions and 44 deletions
@@ -8,6 +8,7 @@ from nonebot_plugin_apscheduler import scheduler
from zhenxun.configs.utils import PluginExtraData, Task
from zhenxun.models.group_console import GroupConsole
from zhenxun.models.task_info import TaskInfo
from zhenxun.services.cache.runtime_cache import TaskInfoMemoryCache
from zhenxun.services.log import logger
from zhenxun.utils.common_utils import CommonUtils
from zhenxun.utils.manager.priority_manager import PriorityLifecycle
@@ -89,6 +90,8 @@ async def to_db(
if load_task:
await TaskInfo.filter(module__in=load_task).update(load_status=True)
await TaskInfo.filter(module__not_in=load_task).update(load_status=False)
if create_list or update_list or load_task:
await TaskInfoMemoryCache.refresh()
async def get_run_task(task: Task, *args, **kwargs):
@@ -144,6 +147,7 @@ async def _():
await _handle_setting(plugin, task_info_list, task_list)
if not task_info_list:
await TaskInfo.all().update(load_status=False)
await TaskInfoMemoryCache.refresh()
return
module_dict = {t[1]: t[0] for t in await TaskInfo.all().values_list("id", "module")}
load_task = []