dynamodb#

DynamoDB backend for cache.

class pynamodb_mate.patterns.cache.backend.dynamodb.DynamoDBBackend(table_name: str, region: str, billing_mode: Optional[str] = 'PAY_PER_REQUEST', write_capacity_units: Optional[int] = None, read_capacity_units: Optional[int] = None, create: bool = True)[source]#

Base class for DynamoDB cache backend. You have to implement your own serialize() and deserialize() methods before use.

Parameters:
  • table_name – DynamoDB table name

  • region – aws region

  • billing_mode – billing model to use when creating the table

  • write_capacity_units – WCU configuration when creating the table

  • read_capacity_units – RCU configuration when creating the table

  • create – if True, create the table when initializing the backend, if table already exists, then do nothing. if False, you should create the table manually before using the backend.

clear_all()[source]#

Disable all records in cache.

clear_expired()[source]#

Disable all expired records in cache.

class pynamodb_mate.patterns.cache.backend.dynamodb.JsonDictDynamodbCache(table_name: str, region: str, billing_mode: Optional[str] = 'PAY_PER_REQUEST', write_capacity_units: Optional[int] = None, read_capacity_units: Optional[int] = None, create: bool = True)[source]#

A built-in Dynamodb cache designed to store JSON serializable dict.

serialize(value: dict) bytes[source]#

Abstract serialization function that convert the original value to binary data.

deserialize(value: bytes) dict[source]#

Abstract deserialization function the recover the original value from binary data.

class pynamodb_mate.patterns.cache.backend.dynamodb.JsonListDynamodbCache(table_name: str, region: str, billing_mode: Optional[str] = 'PAY_PER_REQUEST', write_capacity_units: Optional[int] = None, read_capacity_units: Optional[int] = None, create: bool = True)[source]#

A built-in Dynamodb cache designed to store JSON serializable list.

serialize(value: list) bytes[source]#

Abstract serialization function that convert the original value to binary data.

deserialize(value: bytes) list[source]#

Abstract deserialization function the recover the original value from binary data.