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.0.4.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

fastapi_cachepot-0.0.4-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_cachepot-0.0.4.tar.gz.

File metadata

  • Download URL: fastapi_cachepot-0.0.4.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.9 Darwin/23.2.0

File hashes

Hashes for fastapi_cachepot-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d9a58dcd7788e682f5cebf0d258fbdf759f7a51592fc23274bee3fc2f2a1b514
MD5 560d00118c48f921dc1d53d5af59ff46
BLAKE2b-256 20f192f1394f83db4c78e49434544c95346157e883af4551e84e2286a33a90a5

See more details on using hashes here.

File details

Details for the file fastapi_cachepot-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_cachepot-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1d5b63f91b63ccbfc9ba37b04cac8e69015e238427fb1ecdb45b501045c46125
MD5 6de1f4d0d41b0e611f698386ad7b80e3
BLAKE2b-256 e96f24f9fce74809df6f042c2953f77ea2caa4b50fe5120205d193ec740a2590

See more details on using hashes here.

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