mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor: route cache settings through runtime
This commit is contained in:
Vendored
+13
-6
@@ -14,7 +14,12 @@ from app.runtime.cache import (
|
||||
DEFAULT_CACHE_REGION,
|
||||
configure_cache_factories,
|
||||
)
|
||||
from app.runtime.config import settings
|
||||
from app.runtime import config as _runtime_config
|
||||
from app.runtime.settings import get_runtime_setting
|
||||
|
||||
|
||||
# 兼容旧插件对模块级 Settings 的覆盖,工厂实际读取统一经过 runtime 端口。
|
||||
settings = _runtime_config.settings
|
||||
|
||||
|
||||
class RedisBackend(CacheBackend):
|
||||
@@ -330,12 +335,14 @@ class AsyncFileBackend(AsyncCacheBackend):
|
||||
def configure_platform_cache() -> None:
|
||||
"""把配置感知的 Redis 与文件适配器注册到平台缓存工厂。"""
|
||||
configure_cache_factories(
|
||||
backend_type_provider=lambda: settings.CACHE_BACKEND_TYPE,
|
||||
backend_type_provider=lambda: get_runtime_setting("CACHE_BACKEND_TYPE"),
|
||||
redis_factory=lambda ttl: RedisBackend(ttl=ttl),
|
||||
async_redis_factory=lambda ttl: AsyncRedisBackend(ttl=ttl),
|
||||
file_factory=lambda base: FileBackend(base=base or settings.TEMP_PATH),
|
||||
async_file_factory=lambda base: AsyncFileBackend(
|
||||
base=base or settings.TEMP_PATH
|
||||
file_factory=lambda base: FileBackend(
|
||||
base=base or get_runtime_setting("TEMP_PATH")
|
||||
),
|
||||
file_ttl_provider=lambda: settings.TEMP_FILE_DAYS * 24 * 3600,
|
||||
async_file_factory=lambda base: AsyncFileBackend(
|
||||
base=base or get_runtime_setting("TEMP_PATH")
|
||||
),
|
||||
file_ttl_provider=lambda: get_runtime_setting("TEMP_FILE_DAYS") * 24 * 3600,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user