Skip to main content

DynamoDBBackend

AWS DynamoDB result backend.

Attributes​

AttributeTypeDescription
table_namestring = celerydefault DynamoDB table name (default)
read_capacity_unitsint = 1Read Provisioned Throughput (default)
write_capacity_unitsint = 1Write Provisioned Throughput (default)
aws_regionstring = nullAWS region (default)
endpoint_urlstring = nullThe endpoint URL that is passed to boto3 (local DynamoDB) (default)
time_to_live_secondsint = nullItem time-to-live in seconds (default)
supports_autoexpireboolean = trueIndicates that DynamoDB supports Time to Live as an auto-expiry mechanism.
implements_incrboolean = trueIndicates that the backend supports atomic increment operations for chord functionality.

Constructor​

Signature​

def DynamoDBBackend(
url: str = null,
table_name: str = null,
*args: any = null,
**kwargs: any = null
) - > null

Parameters​

NameTypeDescription
urlstr = nullThe connection URL containing configuration details like region, credentials, and table name.
table_namestr = nullThe name of the DynamoDB table to use for storing results.
*argsany = nullVariable length argument list passed to the parent class.
**kwargsany = nullArbitrary keyword arguments passed to the parent class.

Methods​


client()​

@classmethod
def client() - > botocore.client.DynamoDB

Provides access to the underlying Boto3 DynamoDB client, initializing it if necessary.

Returns​

TypeDescription
botocore.client.DynamoDBThe active DynamoDB client instance

get()​

@classmethod
def get(
key: any
) - > bytes | null

Retrieves the value associated with a specific key from the DynamoDB table.

Parameters​

NameTypeDescription
keyanyThe key used to look up the stored result

Returns​

TypeDescription
`bytesnull`

set()​

@classmethod
def set(
key: any,
value: bytes
) - > null

Stores a value in the DynamoDB table for a given key, including a timestamp and optional TTL.

Parameters​

NameTypeDescription
keyanyThe key under which the value will be stored
valuebytesThe binary data to store

Returns​

TypeDescription
nullnull

mget()​

@classmethod
def mget(
keys: list
) - > list

Retrieves multiple values from the backend for a list of provided keys.

Parameters​

NameTypeDescription
keyslistA collection of keys to retrieve

Returns​

TypeDescription
listA list of binary values corresponding to the input keys

delete()​

@classmethod
def delete(
key: any
) - > null

Removes the item associated with the specified key from the DynamoDB table.

Parameters​

NameTypeDescription
keyanyThe key of the item to be deleted

Returns​

TypeDescription
nullnull

incr()​

@classmethod
def incr(
key: bytes
) - > int

Atomically increase the chord_count and return the new count

Parameters​

NameTypeDescription
keybytesThe key identifying the counter to increment

Returns​

TypeDescription
intThe new integer value of the counter after incrementing