Caching middleware for aiohttp server with aiocache under the hood
Project description
aiohttp-aiocache
Caching middleware for aiohttp server with aiocache under the hood. Inspired by aiohttp-cache.
Installation
pip install aiohttp-aiocache
or
poetry add aiohttp-aiocache
Optional aiocache
dependencies for redis, memcached and msgpack support
will not be installed. Install them manually if required.
Usage
import asyncio import aiohttp.web as web from aiocache import Cache from aiocache.serializers import PickleSerializer from aiohttp_aiocache import cached, register_cache @cached # mark handler with decorator async def handler(_: web.Request) -> web.Response: await asyncio.sleep(1) return web.Response(text="Hello world") app = web.Application() app.router.add_route("GET", "/", handler) # create aiocache instance cache = Cache( Cache.MEMORY, serializer=PickleSerializer(), namespace="main", ttl=60, ) # register cache backend in appplication register_cache(app, cache) web.run_app(app)
Limitations
Support caching for GET requests only.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size aiohttp_aiocache-0.1.0-py3-none-any.whl (4.7 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size aiohttp-aiocache-0.1.0.tar.gz (3.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for aiohttp_aiocache-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ebcf2877b16858bdbddf7d921263fae3818a06b0800fff2bdae8a09f69a847d |
|
MD5 | 4b5fe6f2bb6e249516fa8adb68a2d7ac |
|
BLAKE2-256 | cc54333a5764125e91f75dcc9f54339d8014329ad7cd990cb4f466f5a920e8f9 |