session

Summary

CacheMixin([base_url, cache])

A mixin class for aiohttp.ClientSession that adds caching support

CachedSession([base_url, cache])

A drop-in replacement for aiohttp.ClientSession that adds caching support

Module Contents

class CachedSession(base_url=None, *, cache=None, **kwargs)

Bases: CacheMixin, ClientSession

A drop-in replacement for aiohttp.ClientSession that adds caching support

Parameters:
async _request(method, str_or_url, expire_after=None, refresh=False, **kwargs)

Wrapper around SessionClient._request() that adds caching

Args:

Parameters:
Return type:

CachedResponse

async delete_expired_responses()

Remove all expired responses from the cache

disabled()

Temporarily disable the cache

Example

>>> async with CachedSession() as session:
>>>     await session.get('http://httpbin.org/ip')
>>>     async with session.disabled():
>>>         # Will return a new response, not a cached one
>>>         await session.get('http://httpbin.org/ip')
class CacheMixin(base_url=None, *, cache=None, **kwargs)

A mixin class for aiohttp.ClientSession that adds caching support

Parameters: