From a6aad8b8ea351836174305ab602ff7abb1380855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=85=E8=AF=BA=E7=8B=90?= <212194964+foxcyber907@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:52:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Revert=20"fix(redis):=20=E6=B7=BB=E5=8A=A0R?= =?UTF-8?q?edis=E7=BC=93=E5=AD=98=E6=A8=A1=E5=9D=97=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f76cf36bae892b426922f4807003b2d5d29741f6. --- src/common/database/optimization/__init__.py | 5 +++++ src/common/database/optimization/cache_manager.py | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/database/optimization/__init__.py b/src/common/database/optimization/__init__.py index fbbf10375..4a6e43031 100644 --- a/src/common/database/optimization/__init__.py +++ b/src/common/database/optimization/__init__.py @@ -33,6 +33,7 @@ from .preloader import ( get_preloader, record_preload_access, ) +from .redis_cache import RedisCache, close_redis_cache, get_redis_cache __all__ = [ "AccessPattern", @@ -52,12 +53,16 @@ __all__ = [ # Memory Cache "MultiLevelCache", "Priority", + # Redis Cache + "RedisCache", "close_batch_scheduler", "close_cache", "close_preloader", + "close_redis_cache", "get_batch_scheduler", "get_cache", "get_cache_backend_type", "get_preloader", "record_preload_access", + "get_redis_cache" ] diff --git a/src/common/database/optimization/cache_manager.py b/src/common/database/optimization/cache_manager.py index 81ce1f5ed..e22797af1 100644 --- a/src/common/database/optimization/cache_manager.py +++ b/src/common/database/optimization/cache_manager.py @@ -887,12 +887,7 @@ async def _create_redis_cache(db_config: Any) -> CacheBackend: Raises: RuntimeError: Redis 连接失败时抛出异常 """ - try: - from src.common.database.optimization.redis_cache import RedisCache - except ModuleNotFoundError as exc: - raise RuntimeError( - "Redis 缓存后端需要可选依赖 'redis',请执行 `pip install redis` 或将 cache_backend 配置为 'memory'" - ) from exc + from src.common.database.optimization.redis_cache import RedisCache logger.info( f"创建 Redis 缓存: {db_config.redis_host}:{db_config.redis_port}/{db_config.redis_db}, " From 90da041fa66d575c2b73bab8b99730fa013c053b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=85=E8=AF=BA=E7=8B=90?= <212194964+foxcyber907@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:53:21 +0800 Subject: [PATCH 2/2] Update pyproject.toml --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9bde91e29..ae1304aa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,7 +83,8 @@ dependencies = [ "fastmcp>=2.13.0", "mofox-wire", "jinja2>=3.1.0", - "psycopg2-binary" + "psycopg2-binary", + "redis>=7.1.0", ] [[tool.uv.index]]