Skip to content

hyperion.adapters.cache.dynamodb

hyperion.adapters.cache.dynamodb

DynamoDB-backed :class:Cache adapter (requires boto3 -- [aws]).

DynamoDBCache

DynamoDBCache(prefix, hash_keys=True, default_ttl=DEFAULT_TTL_SECONDS, table_name=None)

Bases: Cache

A DynamoDB cache for our shenanigans.

Source code in hyperion/adapters/cache/dynamodb.py
def __init__(
    self, prefix: str, hash_keys: bool = True, default_ttl: int = DEFAULT_TTL_SECONDS, table_name: str | None = None
):
    super().__init__(prefix, hash_keys, default_ttl)
    self.client = boto3.resource("dynamodb")
    if table_name is None:
        raise ValueError("No table_name was provided for DynamoDBCache.")
    self.table_name = table_name
    self.table = self.client.Table(table_name)