Skip to main content
Version: Next

SqlKeyValueStoreClient

SQL implementation of the key-value store client.

This client persists key-value data to a SQL database with transaction support and concurrent access safety. Keys are mapped to rows in database tables with proper indexing for efficient retrieval.

The key-value store data is stored in SQL database tables following the pattern:

  • key_value_stores table: Contains store metadata (id, name, timestamps)
  • key_value_store_records table: Contains individual key-value pairs with binary value storage, content type, and size information
  • key_value_store_metadata_buffer table: Buffers metadata updates for performance optimization

Values are serialized based on their type: JSON objects are stored as formatted JSON, text values as UTF-8 encoded strings, and binary data as-is in the LargeBinary column. The implementation automatically handles content type detection and maintains metadata about each record including size and MIME type information.

All database operations are wrapped in transactions with proper error handling and rollback mechanisms. The client supports atomic upsert operations and handles race conditions when multiple clients access the same store using composite primary keys (key_value_store_id, key).

Hierarchy

Index

Methods

__init__

  • __init__(*, storage_client, id): None
  • Initialize a new instance.

    Preferably use the SqlKeyValueStoreClient.open class method to create a new instance.


    Parameters

    Returns None

delete_value

  • async delete_value(*, key): None
  • Delete a value from the key-value store by its key.

    The backend method for the KeyValueStore.delete_value call.


    Parameters

    • keyword-onlykey: str

    Returns None

drop

  • async drop(): None
  • Delete this key-value store and all its records from the database.

    This operation is irreversible. Uses CASCADE deletion to remove all related records.


    Returns None

get_metadata

get_public_url

  • async get_public_url(*, key): str
  • Get the public URL for the given key.

    The backend method for the KeyValueStore.get_public_url call.


    Parameters

    • keyword-onlykey: str

    Returns str

get_session

  • async get_session(*,