Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Cached dependencies #29

Open
florimondmanca opened this issue Sep 11, 2019 · 0 comments · May be fixed by #38
Open

Cached dependencies #29

florimondmanca opened this issue Sep 11, 2019 · 0 comments · May be fixed by #38

Comments

@florimondmanca
Copy link
Member

florimondmanca commented Sep 11, 2019

Example:

from bocadillo import App
from asyncdeps import depends, cached
from databases import Database

app = App()

@cached
async def get_db() -> Database:
    async with Database("sqlite://:memory:") as db:
        yield db

@app.route("/")
async def home(req, res, message: Database = depends(get_db)):
    res.text = message
@florimondmanca florimondmanca linked a pull request Sep 13, 2019 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant