Skip to main content

aiohttp-aiocache

Maintainability Test Coverage

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)

Source distribution for aiohttp-aiocache 0.1.0
File Size Uploaded
aiohttp-aiocache-0.1.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-aiocache 0.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page