mirror of
https://github.com/long2ice/fastapi-cache.git
synced 2026-03-25 04:57:54 +00:00
Merge branch 'main' into fix-no-cache
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# pyright: reportGeneralTypeIssues=false
|
||||
from typing import Dict, Optional
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import AsyncIterator, Dict, Optional
|
||||
|
||||
import pendulum
|
||||
import uvicorn
|
||||
@@ -11,7 +12,13 @@ from pydantic import BaseModel
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import JSONResponse, Response
|
||||
|
||||
app = FastAPI()
|
||||
@asynccontextmanager
|
||||
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
|
||||
FastAPICache.init(InMemoryBackend())
|
||||
yield
|
||||
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
|
||||
ret = 0
|
||||
|
||||
@@ -128,10 +135,5 @@ def namespaced_injection(
|
||||
}
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
FastAPICache.init(InMemoryBackend())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("main:app", reload=True)
|
||||
|
||||
Reference in New Issue
Block a user