-
Implement dependency cache per request.
- This avoids calling each dependency multiple times for the same request.
- This is useful while calling external services, performing costly computation, etc.
- This also means that if a dependency was declared as a path operation decorator dependency, possibly at the router level (with
.include_router()
) and then it is declared again in a specific path operation, the dependency will be called only once. - The cache can be disabled per dependency declaration, using
use_cache=False
as inDepends(your_dependency, use_cache=False)
. - Updated docs at: Using the same dependency multiple times.
- PR #292.
-
Implement dependency overrides for testing.
- This allows using overrides/mocks of dependencies during tests.
- New docs: Testing Dependencies with Overrides.
- PR #291.