A simple, lightweight caching system implemented as FastAPI dependencies for improving API performance.
FastAPI Cache is a lightweight caching library for FastAPI applications that implements caching as dependencies. It solves the problem of repetitive database queries or expensive computations by storing and retrieving cached data, thereby improving API response times and reducing server load.
FastAPI developers building high-performance web APIs who need to implement caching to optimize endpoint responses and handle increased traffic efficiently.
Developers choose FastAPI Cache for its seamless integration with FastAPI's dependency system, support for multiple cache backends like Redis, and its minimal, straightforward API that avoids over-engineering while covering essential caching needs.
FastAPI simple cache
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Seamlessly integrates with FastAPI's dependency system, allowing cache access to be injected cleanly into endpoints, as demonstrated in the usage example where `RedisCacheBackend` is used as a dependency.
Supports both Redis and in-memory backends, providing deployment flexibility for local development or distributed environments, as highlighted in the key features.
Includes time-to-live functionality for cache expiration in both backends, essential for managing stale data, with recent updates adding TTL for in-memory caching as noted in the changelog.
Offers straightforward get and set methods, reducing boilerplate code and aligning with FastAPI's simplicity ethos, as emphasized in the philosophy section.
The README's TODO list admits missing features like a dependency for request caching, limiting advanced use cases such as automatic response caching without manual implementation.
Requires manual configuration of startup and shutdown events for cache initialization and cleanup, as shown in the usage example, which can be error-prone compared to more automated libraries.
With version 0.1.0 and breaking changes in the changelog (e.g., removed default TTL), the library may lack stability for production without careful version pinning and testing.