api: add tooling for keeping a local cache

This commit is contained in:
lilly 2026-05-07 21:38:22 +02:00
commit bc7e74f28d
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g
4 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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)]