⚡️ Use Redis to cache REST responses
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user