File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -21,14 +21,16 @@ The `@cache` decorator provides a simple interface for adding caching to any Fas
2121### Basic Usage
2222
2323``` python
24- from fastapi import APIRouter, Request
24+ from fastapi import APIRouter, Request, Depends
25+ from sqlalchemy.orm import Session
2526from app.core.utils.cache import cache
27+ from app.core.db.database import get_db
2628
2729router = APIRouter()
2830
2931@router.get (" /posts/{post_id} " )
3032@cache (key_prefix = " post_cache" , expiration = 3600 )
31- async def get_post (request : Request, post_id : int ):
33+ async def get_post (request : Request, post_id : int , db : Session = Depends(get_db) ):
3234 # This function's result will be cached for 1 hour
3335 post = await crud_posts.get(db = db, id = post_id)
3436 return post
You can’t perform that action at this time.
0 commit comments