mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-06 12:20:00 +08:00
性能优化 (#2126)
* 性能优化 * 代码改进 * 优化浏览器代际切换逻辑 * 统一缓存与生命周期 * 添加aiomysql依赖 * 优化插件路径处理逻辑,简化条件判断;在虚拟环境包管理器中添加编码和错误处理参数以增强稳定性 * 🚨 auto fix by pre-commit hooks * 优化Windows下的关闭逻辑 * 代码优化 * bugfix:修复配置重载问题 * bugfix:修复插件加载启动竞态问题 * 收敛事件入口和权限上下文 * 优化 Windows launcher 关闭重启兜底 --------- Co-authored-by: HibiKier <775757368@qq.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
HibiKier
pre-commit-ci[bot]
parent
24c316cd2c
commit
5d92ccd3b0
Vendored
+10
-6
@@ -74,6 +74,7 @@ from .config import (
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"BoundedTTLCache",
|
||||
"Cache",
|
||||
"CacheDict",
|
||||
"CacheManager",
|
||||
@@ -82,6 +83,7 @@ __all__ = [
|
||||
]
|
||||
|
||||
from . import runtime_cache as _runtime_cache # noqa: F401
|
||||
from .bounded_ttl import BoundedTTLCache
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
@@ -400,9 +402,10 @@ class CacheManager:
|
||||
"""清除缓存
|
||||
|
||||
参数:
|
||||
cache_type: 缓存类型,为None时清除所有缓存。
|
||||
注意:受 aiocache 限制,无法按类型精确删除,
|
||||
指定 cache_type 时仅清除整个 backend(行为与不指定相同)。
|
||||
cache_type: 缓存类型。为 None 时清除整个 backend。
|
||||
指定 cache_type 时不再退化为清除整个 backend,避免误删其他类型缓存。
|
||||
需要刷新模型运行态缓存时,应调用对应
|
||||
RuntimeCache.refresh/upsert/remove。
|
||||
|
||||
返回:
|
||||
bool: 是否成功
|
||||
@@ -413,11 +416,12 @@ class CacheManager:
|
||||
|
||||
try:
|
||||
if cache_type:
|
||||
logger.debug(
|
||||
f"清除缓存类型 {cache_type}"
|
||||
"(aiocache 不支持按前缀删除,清除整个 backend)",
|
||||
logger.warning(
|
||||
f"拒绝清除缓存类型 {cache_type}: "
|
||||
"当前后端不支持可靠的按类型清理,已避免清除整个 backend",
|
||||
LOG_COMMAND,
|
||||
)
|
||||
return False
|
||||
await self.cache_backend.clear() # type: ignore
|
||||
return True
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user