mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-24 20:47:54 +00:00
feat: cache response obj add test case
This commit is contained in:
@@ -6,7 +6,7 @@ import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from redis.asyncio.connection import ConnectionPool
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import Response
|
||||
from starlette.responses import Response, JSONResponse
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
@@ -73,6 +73,12 @@ async def cache_html(request: Request):
|
||||
})
|
||||
|
||||
|
||||
@app.get("/cache_response_obj")
|
||||
@cache(namespace="test", expire=5)
|
||||
async def cache_response_obj():
|
||||
return JSONResponse({"a": 1})
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
pool = ConnectionPool.from_url(url="redis://redis")
|
||||
|
||||
Reference in New Issue
Block a user