Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /allen0099_FastAPI-CacheX /fastapi_cachex /dependencies.py
| """FastAPI dependency injection utilities for cache control.""" | |
| from typing import Annotated | |
| from fastapi import Depends | |
| from .backends.base import BaseCacheBackend | |
| from .exceptions import BackendNotFoundError | |
| from .manager import CacheManager | |
| from .manager_proxy import CacheManagerProxy | |
| from .proxy import BackendProxy | |
| def get_cache_backend() -> BaseCacheBackend: | |
| """Dependency to get the current cache backend instance.""" | |
| return BackendProxy.get() | |
| CacheBackend = Annotated[BaseCacheBackend, Depends(get_cache_backend)] | |
| def get_app_cache() -> CacheManager: | |
| """Dependency to get the application CacheManager instance. | |
| Lazily creates and registers a default CacheManager (backed by | |
| BackendProxy) the first time it's requested, unless one was already | |
| set via CacheManagerProxy.set(...). | |
| """ | |
| try: | |
| return CacheManagerProxy.get() | |
| except BackendNotFoundError: | |
| manager = CacheManager() | |
| CacheManagerProxy.set(manager) | |
| return manager | |
| AppCache = Annotated[CacheManager, Depends(get_app_cache)] | |
Xet Storage Details
- Size:
- 1.07 kB
- Xet hash:
- d2db74ace387dbbbcae8b0036171a0b56860d9a2219f8f310cdacc1f32a13d4c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.