Fix: Descartar y eliminar del caché valores contaminados con mensajes de error (#12)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user