Skip to main content

A caching library specially designed for FastAPI

Project description

CachiPy: A Caching Library for FastAPI

CachiPy is a caching library specially designed for use with FastAPI. It allows you to easily cache API responses and improve the performance of your FastAPI applications.

CachiPy Logo

Features

  • Simple and efficient caching for FastAPI applications.
  • Support for caching API responses and function results.
  • Easy integration with FastAPI routes.
  • Customizable cache size and eviction policies.
  • Automatic cache clearing.

Installation

You can install CachiPy using pip:

pip install CachiPy

Usage

from fastapi import FastAPI
from CachiPy import cacheit
import time

app = FastAPI()

@cacheit
def factorial(n):
    if n <= 1:
        return 1
    else:
        return n * factorial(n - 1)

# ... define FastAPI routes and route handlers ...

# Use @cacheit decorator to cache results within your route handlers.

Example usage:

@app.get("/factorial/{n}")
def calculate_factorial(n: int):
    result = factorial(n)
    return {
        "result": result,
        "execution_time": end_time - start_time
    }

Screenshots

Before Caching

After Caching

License

This library is released under the MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Please read our Contribution Guidelines for more details.

Support

If you encounter any issues or have questions, please open an issue on GitHub.

Acknowledgments

Thank you to the FastAPI community for inspiration and support.

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

CachiPy-0.0.5.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

CachiPy-0.0.5-py3-none-any.whl (3.3 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