dynamodb¶
Summary¶
|
|
|
An async interface for caching objects in a DynamoDB key-store |
Module Contents¶
- class DynamoDBBackend(cache_name='aiohttp-cache', key_attr_name='k', val_attr_name='v', create_if_not_exists=False, context=None, **kwargs)¶
Bases:
CacheBackend
Async cache backend for DynamoDB
Notes
Requires aioboto3
Accepts keyword arguments for
boto3.session.Session.client()
See DynamoDB Service Resource for more usage details.
DynamoDB has a maximum item size of 400KB. If an item exceeds this size, it will not be written to the cache.
- Parameters:
cache_name (
str
) – Table name to usekey_attr_name (
str
) – The name of the field to use for keys in the DynamoDB documentval_attr_name (
str
) – The name of the field to use for values in the DynamoDB documentcreate_if_not_exists (
bool
) – Whether or not to attempt to create the DynamoDB tablecontext (
ResourceCreatorContext
|None
) – An existing ResourceCreatorContext to reuse instead of creating a new onekwargs (
Any
) – Additional keyword arguments forCacheBackend
or backend connection
- class DynamoDbCache(table_name, namespace, key_attr_name='k', val_attr_name='v', create_if_not_exists=False, context=None, **kwargs)¶
Bases:
BaseCache
An async interface for caching objects in a DynamoDB key-store
The actual key name on the dynamodb server will be
namespace:key
. In order to deal with how dynamodb stores data/keys, all values must be serialized.- Parameters:
- async bulk_delete(keys)¶
Delete item(s) from the cache. Does not raise an error if the item is missing.
- async delete(key)¶
Delete an item from the cache. Does not raise an error if the item is missing.
- get_connection()¶
- async get_table()¶
- async keys()¶
Get all keys stored in the cache
- Return type:
- async read(key)¶
Read an item from the cache. Returns
None
if the item is missing.
- async values()¶
Get all values stored in the cache
- Return type: