Cache library for FastAPI with tag based invalidation. Asynchronous only for the time being.
- Automatic response cache fetching using FastAPI dependencies
- Fine-grained control over when to return and set the cache
- Ability to invalidate cached objects based on a concept of associated tags. See examples/redis_app for an example.
With in-memory support only:
pip install fastapi-caching
NOTE: In-memory backend is only recommended when your app is only run as a single instance.
With redis support (through the aioredis library):
pip install fastapi-caching[redis]
Examples on how to use can be found here.
- Only supported within async contexts.
- Feature: Support lazy setup of cache manager
- Breaking change: Revert to requiring
backend
to be passed to CacheManager - Feature: Support lazy configuration of the caching backend
- Feature: Add functionality to disable (and re-enable) caching.