Preparar repositorio para despliegue: código fuente limpio
This commit is contained in:
parent
866f5c432d
commit
3eca832c1a
76 changed files with 5434 additions and 3496 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue