️ Use Redis to cache REST responses

This commit is contained in:
2023-05-26 18:10:47 +02:00
parent cd700ebd42
commit e2ff90cd5f
7 changed files with 87 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
from fastapi import APIRouter, HTTPException
from fastapi_cache.decorator import cache
from backend.models import Line
from backend.schemas import Line as LineSchema, TransportMode
@@ -8,6 +9,7 @@ router = APIRouter(prefix="/line", tags=["line"])
@router.get("/{line_id}", response_model=LineSchema)
@cache(namespace="line")
async def get_line(line_id: int) -> LineSchema:
line: Line | None = await Line.get_by_id(line_id)