Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /allen0099_FastAPI-CacheX /fastapi_cachex /state /dependencies.py
| """FastAPI dependency injection utilities for state management.""" | |
| from typing import Annotated | |
| from fastapi import Depends | |
| from fastapi_cachex.exceptions import BackendNotFoundError | |
| from .manager import StateManager | |
| from .proxy import StateManagerProxy | |
| def get_state_manager() -> StateManager: | |
| """Dependency to get the application StateManager instance. | |
| Lazily creates and registers a default StateManager (backed by | |
| BackendProxy) the first time it's requested, unless one was already | |
| set via StateManagerProxy.set(...). | |
| """ | |
| try: | |
| return StateManagerProxy.get() | |
| except BackendNotFoundError: | |
| manager = StateManager() | |
| StateManagerProxy.set(manager) | |
| return manager | |
| StateManagerDep = Annotated[StateManager, Depends(get_state_manager)] | |
Xet Storage Details
- Size:
- 801 Bytes
- Xet hash:
- edc48c63db4f712929a7a759125e35924aad461fe689fff52dda22ce44461bfb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.