fix: 修复 Redis SCAN cursor 类型问题并优化缓存清除日志

- CacheService.delete_pattern 中 cursor 可能为 int 或 str,统一转为 int 比较
- 模型缓存清除时区分有/无缓存的日志级别(info/debug)
This commit is contained in:
fawney19
2026-01-23 16:23:17 +08:00
parent 6f597a5f54
commit f45fd06fb0
2 changed files with 7 additions and 3 deletions

View File

@@ -73,7 +73,10 @@ async def invalidate_models_list_cache() -> None:
try:
# 使用通配符删除所有 models:list:* 缓存(包括多格式组合的 key
deleted = await CacheService.delete_pattern(f"{_CACHE_KEY_PREFIX}:*")
logger.debug(f"[ModelsService] 已清除 {deleted}{_CACHE_KEY_PREFIX} 缓存")
if deleted > 0:
logger.info(f"[ModelsService] 已清除 {deleted}{_CACHE_KEY_PREFIX} 缓存")
else:
logger.debug(f"[ModelsService] 无 {_CACHE_KEY_PREFIX} 缓存需要清除")
except Exception as e:
logger.warning(f"[ModelsService] 清除缓存失败: {e}")