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.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohttp-aiocache-0.1.0.tar.gz.
File metadata
- Download URL: aiohttp-aiocache-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.7.5 Linux/5.0.0-1027-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ff4bb4badf5af184f6f438b534356395684a121650ae9e18e2901d300fd6270
|
|
| MD5 |
c710ac6dd00e4037c04d851d085c8384
|
|
| BLAKE2b-256 |
5c666e0ce9b8a34209c07839e2166adab9b015044e5ff556aa20448a66fd87ee
|
File details
Details for the file aiohttp_aiocache-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiohttp_aiocache-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.7.5 Linux/5.0.0-1027-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ebcf2877b16858bdbddf7d921263fae3818a06b0800fff2bdae8a09f69a847d
|
|
| MD5 |
4b5fe6f2bb6e249516fa8adb68a2d7ac
|
|
| BLAKE2b-256 |
cc54333a5764125e91f75dcc9f54339d8014329ad7cd990cb4f466f5a920e8f9
|