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: aiohttp_client_cache.session.CacheMixin, aiohttp.ClientSession

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

Parameters
async _request(method, str_or_url, **kwargs)

Wrapper around SessionClient._request() that adds caching

Return type

Union[ClientResponse, CachedResponse]

Parameters
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