From ad0241b7f105097a6bff085bc23e841e99dcea15 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Sat, 18 Jan 2025 02:44:56 +0800 Subject: [PATCH] feat(cache): set default skip_empty to False --- app/core/cache.py | 4 ++-- app/helper/plugin.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/core/cache.py b/app/core/cache.py index 86897cf5..2b8a85cb 100644 --- a/app/core/cache.py +++ b/app/core/cache.py @@ -249,7 +249,7 @@ def get_cache_backend(maxsize: int = 1000, ttl: int = 1800) -> CacheBackend: def cached(region: str = DEFAULT_CACHE_REGION, maxsize: int = 1000, ttl: int = 1800, - skip_none: bool = True, skip_empty: bool = True): + skip_none: bool = True, skip_empty: bool = False): """ 自定义缓存装饰器,支持为每个 key 动态传递 maxsize 和 ttl @@ -257,7 +257,7 @@ def cached(region: str = DEFAULT_CACHE_REGION, maxsize: int = 1000, ttl: int = 1 :param maxsize: 缓存的最大条目数,默认值为 1000 :param ttl: 缓存的存活时间,单位秒,默认值为 1800 :param skip_none: 跳过 None 缓存,默认为 True - :param skip_empty: 跳过空值缓存(如 [], {}, "", set()),默认为 True + :param skip_empty: 跳过空值缓存(如 [], {}, "", set()),默认为 False :return: 装饰器函数 """ diff --git a/app/helper/plugin.py b/app/helper/plugin.py index 487392e6..616e41b1 100644 --- a/app/helper/plugin.py +++ b/app/helper/plugin.py @@ -38,7 +38,7 @@ class PluginHelper(metaclass=Singleton): if self.install_report(): self.systemconfig.set(SystemConfigKey.PluginInstallReport, "1") - @cached(maxsize=1000, ttl=1800, skip_empty=False) + @cached(maxsize=1000, ttl=1800) def get_plugins(self, repo_url: str, package_version: str = None) -> Optional[Dict[str, dict]]: """ 获取Github所有最新插件列表