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:
aiohttp_client_cache.backends.base.CacheBackend
Async cache backend for DynamoDB (requires aioboto3)
See DynamoDB Service Resource for more usage details.
-
__init__
(cache_name='aiohttp-cache', key_attr_name='k', val_attr_name='v', create_if_not_exists=False, context=None, **kwargs)¶ - 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 (
Optional
[ResourceCreatorContext
]) – An existing ResourceCreatorContext to reuse instead of creating a new oneexpire_after (Union[None, int, float, str, datetime.datetime, datetime.timedelta]) – Time after which a cache entry will be expired; see Cache Expiration for possible formats
urls_expire_after (Dict[str, Union[None, int, float, str, datetime.datetime, datetime.timedelta]]) – Expiration times to apply for different URL patterns
allowed_codes (tuple) – Only cache responses with these status codes
allowed_methods (tuple) – Only cache requests with these HTTP methods
include_headers (bool) – Cache requests with different headers separately
ignored_params (Iterable) – Request parameters to be excluded from the cache key
cache_control (bool) – Use Cache-Control response headers
filter_fn (Callable) – function that takes a
aiohttp.ClientResponse
object and returns a boolean indicating whether or not that response should be cached. Will be applied to both new and previously cached responsessecret_key (Union[Iterable, str, bytes]) – Optional secret key used to sign cache items for added security
salt (Union[str, bytes]) – Optional salt used to sign cache items
serializer – Custom serializer that provides
loads
anddumps
methodsregion_name (str) – The name of the region associated with the client.
api_version (str) – A previous API version to use instead of the latest version
use_ssl (bool) – Whether or not to use SSL. Note that not all services support non-ssl connections.
verify (Union[bool, str]) – Whether or not to verify SSL certificates. You may provide either
False
or a path to the CA cert bundle to use.endpoint_url (str) – The complete URL to use for the constructed client. If this value is provided, then use_ssl is ignored.
aws_access_key_id (str) – The access key to use when creating the client.
aws_secret_access_key (str) – The secret key to use when creating the client.
aws_session_token (str) – The session token to use when creating the client.
config (botocore.config.Config) – Advanced client configuration options. See botocore config documentation for more details.
-
-
class
DynamoDbCache
(table_name, namespace, key_attr_name, val_attr_name, create_if_not_exists, context, **kwargs)¶ Bases:
aiohttp_client_cache.backends.base.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.-
_abc_impl
= <_abc_data object>¶
-
_scan
()¶ - Return type
-
async
delete
(key)¶ Delete an item from the cache. Does not raise an error if the item is missing.
-
async
get_table
()¶
-
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.
-
values
()¶ Get all values stored in the cache
- Return type
-