Skip to main content

A caching library for FastAPI

Project description

FastAPI-Cacher

FastAPI-Cacher is a caching library inspired by Flask-Caching, designed specifically for FastAPI. It provides an easy-to-use decorator-based approach for adding caching to your FastAPI endpoints, making it simple and intuitive.

Features

  • Simple decorator-based caching similar to Flask-Caching.
  • Support for various caching backends (Redis, Memcached, etc.).
  • Easy integration with FastAPI applications.

Installation

To install FastAPI-Cacher, use pip:

pip install fastapi-cacher

Quick Start

Here's an example of how to use FastAPI-Cacher to cache an endpoint:

from fastapi import FastAPI
from fastapi_cacher import FastAPICache, Cache

app = FastAPI()
cache = Cache(app)


@app.get('/')
@cache.cached(timeout=50)
async def index():
    return {'message': 'Hello, world!'}


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=8000)

Contributing

We welcome contributions! Please check the issues on GitHub and feel free to submit pull requests.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi-cacher-0.1.0.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

fastapi_cacher-0.1.0-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page