fix cache

This commit is contained in:
jxxghp
2025-08-20 21:11:10 +08:00
parent 1b2938cbc8
commit f07496a4a0
4 changed files with 40 additions and 32 deletions

View File

@@ -73,8 +73,9 @@ async def fetch_image(
# 没有文件类型,则添加后缀,在恶意文件类型和实际需求下的折衷选择
cache_path = cache_path.with_suffix(".jpg")
# 缓存对像
cache_backend = get_async_file_cache_backend(base=settings.CACHE_PATH)
# 缓存对像,缓存过期时间为全局图片缓存天数
cache_backend = get_async_file_cache_backend(base=settings.CACHE_PATH,
ttl=settings.GLOBAL_IMAGE_CACHE_DAYS * 24 * 3600)
if use_cache:
content = await cache_backend.get(cache_path.as_posix(), region="images")