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 details)
Built Distribution
File details
Details for the file fastapi_cachepot-0.1.0.tar.gz
.
File metadata
- Download URL: fastapi_cachepot-0.1.0.tar.gz
- Upload date:
- Size: 26.3 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 | b3d83bcd3017a3ae094866a5a00ea5c78934dfdb3d4e433c73f036e4824827a9 |
|
MD5 | 628340b192cc520339e35e5f0fba503c |
|
BLAKE2b-256 | 7616f8968cc5cf359fef2365bcaf0f597a7aebc3d4f0bab070c319c0a76ced0f |
File details
Details for the file fastapi_cachepot-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: fastapi_cachepot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.1 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 | afd349a0aaee0aa2f6153b8d178933cb7629bfd21a4e60a297cb8f1125b4780e |
|
MD5 | ac28a084284221786723f0dfd28d3d7a |
|
BLAKE2b-256 | 1d9f801897993bb2aff379bf30c04e2b4757a523384b1d7389931c01f20b681e |