diff --git a/app/core/config.py b/app/core/config.py index 1a8cd160..428f8ad1 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -85,8 +85,8 @@ class ConfigModel(BaseModel): DB_ECHO: bool = False # 数据库连接池类型,QueuePool, NullPool DB_POOL_TYPE: str = "QueuePool" - # 是否在获取连接时进行预先 ping 操作,默认关闭 - DB_POOL_PRE_PING: bool = False + # 是否在获取连接时进行预先 ping 操作 + DB_POOL_PRE_PING: bool = True # 数据库连接的回收时间(秒) DB_POOL_RECYCLE: int = 300 # 数据库连接池获取连接的超时时间(秒) diff --git a/app/core/event.py b/app/core/event.py index 832eae99..a05c70d9 100644 --- a/app/core/event.py +++ b/app/core/event.py @@ -6,7 +6,6 @@ import threading import time import traceback import uuid -from functools import lru_cache from queue import Empty, PriorityQueue from typing import Callable, Dict, List, Optional, Union @@ -263,7 +262,6 @@ class EventManager(metaclass=Singleton): return handler_info @classmethod - @lru_cache(maxsize=1000) def __get_handler_identifier(cls, target: Union[Callable, type]) -> Optional[str]: """ 获取处理器或处理器类的唯一标识符,包括模块名和类名/方法名 @@ -279,7 +277,6 @@ class EventManager(metaclass=Singleton): return f"{module_name}.{qualname}" @classmethod - @lru_cache(maxsize=1000) def __get_class_from_callable(cls, handler: Callable) -> Optional[str]: """ 获取可调用对象所属类的唯一标识符 diff --git a/app/helper/subscribe.py b/app/helper/subscribe.py index de40aab0..91f8347a 100644 --- a/app/helper/subscribe.py +++ b/app/helper/subscribe.py @@ -58,7 +58,7 @@ class SubscribeHelper(metaclass=Singleton): self.get_user_uuid() self.get_github_user() - @cached(maxsize=20, ttl=1800) + @cached(maxsize=5, ttl=1800) def get_statistic(self, stype: str, page: Optional[int] = 1, count: Optional[int] = 30) -> List[dict]: """ 获取订阅统计数据 diff --git a/app/modules/plex/plex.py b/app/modules/plex/plex.py index 8e378c5d..b392a2ae 100644 --- a/app/modules/plex/plex.py +++ b/app/modules/plex/plex.py @@ -84,7 +84,7 @@ class Plex: logger.error(f"Authentication failed: {e}") return None - @cached(maxsize=100, ttl=86400) + @cached(maxsize=32, ttl=86400) def __get_library_images(self, library_key: str, mtype: int) -> Optional[List[str]]: """ 获取媒体服务器最近添加的媒体的图片列表 diff --git a/app/modules/themoviedb/tmdbv3api/objs/trending.py b/app/modules/themoviedb/tmdbv3api/objs/trending.py index 2ea8476a..2688a138 100644 --- a/app/modules/themoviedb/tmdbv3api/objs/trending.py +++ b/app/modules/themoviedb/tmdbv3api/objs/trending.py @@ -1,12 +1,9 @@ -from app.core.cache import cached - from ..tmdb import TMDb class Trending(TMDb): _urls = {"trending": "/trending/%s/%s"} - @cached(maxsize=1024, ttl=43200) def _trending(self, media_type="all", time_window="day", page=1): """ Get trending, TTLCache 12 hours