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.2.tar.gz
(25.0 kB
view details)
Built Distribution
File details
Details for the file fastapi_cachepot-0.0.2.tar.gz
.
File metadata
- Download URL: fastapi_cachepot-0.0.2.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.9 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58e9f5c26c152065300cea56e2aa9c8b0045ea4b9cb9cd171353a7f58726df4f |
|
MD5 | 6c392be00752c896fac2ebd59a9b2163 |
|
BLAKE2b-256 | c767f117d5d69bd71622e55916b906bc9a54f64eeee0c9c337a5f7f64280467a |
File details
Details for the file fastapi_cachepot-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: fastapi_cachepot-0.0.2-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.9 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63bf61732953d5a157a47f389b856cd40bdbeedc90828098b5e031ce026d594f |
|
MD5 | e32564f71b19c60ebfdeaf10ca1034a0 |
|
BLAKE2b-256 | 9072e93c4cca9d5da022aac130de2131e815a257d7f2056ebbd9dec2a2e49b1a |