aiohttp_client_cache.backends.dynamodb module

class aiohttp_client_cache.backends.dynamodb.DynamoDBBackend(cache_name='aiohttp-cache', **kwargs)[source]

Bases: aiohttp_client_cache.backends.base.CacheBackend

DynamoDB cache backend. See DynamoDbCache for backend-specific options See DynamoDB Service Resource for more usage details.

See CacheBackend for args.

class aiohttp_client_cache.backends.dynamodb.DynamoDbCache(table_name, namespace='dynamodb_dict_data', connection=None, region_name='us-east-1', read_capacity_units=1, write_capacity_units=1, **kwargs)[source]

Bases: aiohttp_client_cache.backends.base.BaseCache

An async-compatible interface for caching objects in a DynamoDB key-store

The actual key name on the dynamodb server will be namespace:table_name. In order to deal with how dynamodb stores data/keys, all values must be pickled.

Parameters
  • table_name (str) – Table name to use

  • namespace (str) – Name of the hash map stored in dynamodb

  • connection (Optional[ServiceResource]) – An existing resource object to reuse instead of creating a new one

  • region_name (str) – AWS region of DynamoDB database

  • kwargs – Additional keyword arguments for DynamoDB ServiceResource

_abc_impl = <_abc_data object>
_scan_table()[source]
Return type

Dict

async clear()[source]

Delete all items from the cache

async contains(key)[source]

Check if a key is stored in the cache

Return type

bool

Parameters

key (str) –

async delete(key)[source]

Delete a single item from the cache. Does not raise an error if the item is missing.

Parameters

key (str) –

async keys()[source]

Get all keys stored in the cache

Return type

Iterable[str]

async read(key)[source]

Read a single item from the cache. Returns None if the item is missing.

Return type

Union[CachedResponse, None, bytes, str]

Parameters

key (str) –

async size()[source]

Get the number of items in the cache

Return type

int

static unpickle(response_item)[source]
Return type

Union[CachedResponse, None, bytes, str]

Parameters

response_item (Dict) –

async values()[source]

Get all values stored in the cache

Return type

Iterable[Union[CachedResponse, None, bytes, str]]

async write(key, item)[source]

Write an item to the cache

Parameters