Preparar repositorio para despliegue: código fuente limpio

This commit is contained in:
jlimolina 2026-01-23 02:00:40 +01:00
parent 866f5c432d
commit 3eca832c1a
76 changed files with 5434 additions and 3496 deletions

View file

@ -1,9 +1,19 @@
from typing import List, Dict
from psycopg2 import extras
from cache import cache_get, cache_set
def get_paises(conn) -> List[Dict]:
# Intentar desde caché primero (datos casi estáticos)
cached_data = cache_get("paises:all")
if cached_data:
return cached_data
with conn.cursor(cursor_factory=extras.DictCursor) as cur:
cur.execute("SELECT id, nombre FROM paises ORDER BY nombre;")
return cur.fetchall()
result = cur.fetchall()
# Cachear por 1 hora (son datos estáticos)
cache_set("paises:all", result, ttl_seconds=3600)
return result