api: add tooling for keeping a local cache
This commit is contained in:
parent
51349c297b
commit
bc7e74f28d
4 changed files with 22 additions and 0 deletions
|
|
@ -30,6 +30,9 @@ async def lifespan(app: FastAPI):
|
|||
client_id="dooris",
|
||||
client_secret="dp9HhnvUhAtKm3pRnxfGA7q8Nwrd1td8",
|
||||
)
|
||||
|
||||
app.extra["cache"] = TTLCache(maxsize=64, ttl=30 * 60)
|
||||
|
||||
yield
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -69,3 +69,10 @@ def persist_auth_state(oidc_client: OpenidClient, resp: Response, tokens: TokenS
|
|||
|
||||
CurrentUser = Annotated[Optional[models.CurrentUser], Depends(get_current_user)]
|
||||
|
||||
|
||||
def get_cache(req: Request) -> Cache:
|
||||
return req.app.extra["cache"]
|
||||
|
||||
|
||||
Cache = Annotated[Cache, Depends(get_cache)]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue