Fix: Descartar y eliminar del caché valores contaminados con mensajes de error (#12)

This commit is contained in:
2026-03-20 18:57:24 -06:00
parent e1adb5c390
commit 6ff79f5d69
2 changed files with 18 additions and 9 deletions

View File

@@ -129,10 +129,10 @@ async def translate_text(text: str, target_lang: str) -> str:
translated_segments = await asyncio.gather(*tasks)
result = "".join(translated_segments)
# Guardar en Redis por 24 horas
if result != text:
# No cachear mensajes de error
if result and result != text and "mantenimiento" not in result:
cache_set(redis_key, result, ttl=86400)
return result
return result if result else text
except Exception:
return text