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)
Built Distribution
Close
Hashes for fastapi_cachepot-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd349a0aaee0aa2f6153b8d178933cb7629bfd21a4e60a297cb8f1125b4780e |
|
MD5 | ac28a084284221786723f0dfd28d3d7a |
|
BLAKE2b-256 | 1d9f801897993bb2aff379bf30c04e2b4757a523384b1d7389931c01f20b681e |