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
Release files for aiohttp-aiocache 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiohttp-aiocache-0.1.0.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohttp_aiocache-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / aiohttp-aiocache-0.1.0.tar.gz
| Download URL | aiohttp-aiocache-0.1.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ff4bb4badf5af184f6f438b534356395684a121650ae9e18e2901d300fd6270
|
|
BLAKE2b-256 checksum How to use checksums |
5c666e0ce9b8a34209c07839e2166adab9b015044e5ff556aa20448a66fd87ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.7.5 Linux/5.0.0-1027-azure
|
Release files / aiohttp_aiocache-0.1.0-py3-none-any.whl
| Download URL | aiohttp_aiocache-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ebcf2877b16858bdbddf7d921263fae3818a06b0800fff2bdae8a09f69a847d
|
|
BLAKE2b-256 checksum How to use checksums |
cc54333a5764125e91f75dcc9f54339d8014329ad7cd990cb4f466f5a920e8f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.0 CPython/3.7.5 Linux/5.0.0-1027-azure
|