update:feat: 为声纹识别添加缓存机制

This commit is contained in:
3030332422
2025-08-15 16:58:56 +08:00
parent dcf8c134a2
commit 0bfa5cf723
2 changed files with 30 additions and 7 deletions
+4
View File
@@ -18,6 +18,7 @@ class CacheType(Enum):
IP_INFO = "ip_info"
CONFIG = "config"
DEVICE_PROMPT = "device_prompt"
VOICEPRINT_HEALTH = "voiceprint_health" # 声纹识别健康检查
@dataclass
@@ -54,5 +55,8 @@ class CacheConfig:
CacheType.DEVICE_PROMPT: cls(
strategy=CacheStrategy.TTL, ttl=None, max_size=1000 # 手动失效
),
CacheType.VOICEPRINT_HEALTH: cls(
strategy=CacheStrategy.TTL, ttl=600, max_size=100 # 10分钟过期
),
}
return configs.get(cache_type, cls())