Skip to main content
Version: Next

MemoryKeyValueStoreClient

Memory implementation of the key-value store client.

This client stores data in memory as Python dictionaries. No data is persisted between process runs, meaning all stored data is lost when the program terminates. This implementation is primarily useful for testing, development, and short-lived crawler operations where persistence is not required.

The memory implementation provides fast access to data but is limited by available memory and does not support data sharing across different processes.

Hierarchy

Index

Methods

__init__

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

    Preferably use the MemoryKeyValueStoreClient.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
  • Drop the whole key-value store and remove all its values.

    The backend method for the KeyValueStore.drop call.


    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_value

iterate_entries

  • async iterate_entries(*, exclusive_start_key, limit): AsyncIterator[KeyValueStoreRecord]
  • Iterate over all the existing records in the key-value store, including their values.

    The backend method for the KeyValueStore.iterate_entries and KeyValueStore.iterate_values calls.

    The default implementation lists the keys with iterate_keys and reads each value separately with get_value as the iteration advances, so only a single value is held in memory at a time. Whether a record deleted while the iteration is in progress is yielded depends on the implementation. Backends that can read the keys together with their values more efficiently should override this method; such an implementation must still keep the memory usage bounded, e.g. by streaming or by batching on the known record sizes.


    Parameters

    • optionalkeyword-onlyexclusive_start_key: str | None = None