wip: cache

This commit is contained in:
Jakub Miazek
2024-04-23 19:38:12 +02:00
parent d3a032320c
commit 09674e45de
5 changed files with 271 additions and 76 deletions

View File

@@ -3,6 +3,8 @@ from typing import Annotated
from fastapi import APIRouter, Depends, Query
from sqlalchemy.ext.asyncio import AsyncSession
from fastapi_cache.decorator import cache
from app.database import get_db
from app.models.shakespeare import Paragraph
@@ -12,6 +14,7 @@ router = APIRouter(prefix="/v1/shakespeare")
@router.get(
"/",
)
@cache(namespace="test-2", expire=60)
async def find_paragraph(
character: Annotated[str, Query(description="Character name")],
db_session: AsyncSession = Depends(get_db),