Skip to main content

FastAPI Cache Plus

Static Badge GitHub License GitHub Actions Workflow Status codecov PyPI - Version

This project is a continuation of the project fastapi_cache. Many thanks to Ivan Sushkov (the original author) for their work and contributions.

Implements simple lightweight cache system as dependencies in FastAPI.

Installation

pip install fastapi-cache-plus

Usage example

from fastapi import Depends, FastAPI

from fastapi_cache_plus import caches, close_caches
from fastapi_cache_plus.backends.redis import CACHE_KEY, RedisCacheBackend

app = FastAPI()


def redis_cache():
    return caches.get(CACHE_KEY)


@app.get("/")
async def hello(cache: RedisCacheBackend = Depends(redis_cache)):
    in_cache = await cache.get("some_cached_key")
    if not in_cache:
        await cache.set("some_cached_key", "new_value", 5)

    return {"response": in_cache or "default"}


@app.on_event("startup")
async def on_startup() -> None:
    rc = RedisCacheBackend("redis://redis")
    caches.set(CACHE_KEY, rc)


@app.on_event("shutdown")
async def on_shutdown() -> None:
    await close_caches()

Metadata

Release files for fastapi-cache-plus 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-cache-plus 0.2.0
File Size Uploaded Provenance Actions
fastapi_cache_plus-0.2.0.tar.gz 74.5 kB Without provenance Details for fastapi_cache_plus-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-cache-plus 0.2.0
File Interpreter ABI Platform Actions
fastapi_cache_plus-0.2.0-py3-none-any.whl Python 3 none any Details for fastapi_cache_plus-0.2.0-py3-none-any.whl

Total release size: 80.6 kB

Release files / fastapi_cache_plus-0.2.0.tar.gz

Download URL fastapi_cache_plus-0.2.0.tar.gz
Size 74.5 kB
Tags Source
SHA-256 checksum
How to use checksums
526241a2340a8ecf1ecedefab480da8aec128c4c17d32397d6617d49d6094f81
BLAKE2b-256 checksum
How to use checksums
84ca44243c7bdcc017c2d52397c0ad6fc8330695d8609d06e00175e29f99c4ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.24

Release files / fastapi_cache_plus-0.2.0-py3-none-any.whl

Download URL fastapi_cache_plus-0.2.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a3f243eab144650e86b4d1d28e3234f2ffc4289d21504b04dc9ed6aa399cc1d
BLAKE2b-256 checksum
How to use checksums
7e7ec5831ceae4f950547b336b579900682b66e519ede23a97df7577488079e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.24

Security for fastapi-cache-plus 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page