Skip to main content

The FastAPI cache the way it should be.

Project description

Cachepot

The FastAPI cache the way it should be.

Installation

pip install fastapi-cachepot

Usage

import redis.asyncio as redis

from cachepot.app import CachedFastAPI
from cachepot.constants import CachePolicy
from cachepot.storages import RedisStorage

app = CachedFastAPI()

client = redis.from_url('redis://127.0.0.1:6379')
storage = RedisStorage(client)

cache_policy = CachePolicy(
    storage=storage,
    key='cached_hello_world',
    ttl=30,
)


@app.get(path='', cache_policy=cache_policy)
async def cached_hello_world():
    return {'result': 'hello, world!'}

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_cachepot-0.1.0.tar.gz (26.3 kB view hashes)

Uploaded Source

Built Distribution

fastapi_cachepot-0.1.0-py3-none-any.whl (26.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