CassandraByteStore#

class langchain_community.storage.cassandra.CassandraByteStore(table: str, *, session: Session | None = None, keyspace: str | None = None, setup_mode: SetupMode = SetupMode.SYNC)[source]#

A ByteStore implementation using Cassandra as the backend.

Parameters:
  • table (str) – The name of the table to use.

  • session (Optional[Session]) – A Cassandra session object. If not provided, it will be resolved from the cassio config.

  • keyspace (Optional[str]) – The keyspace to use. If not provided, it will be resolved from the cassio config.

  • setup_mode (SetupMode) – The setup mode to use. Default is SYNC (SetupMode.SYNC).

Methods

__init__(table,Β *[,Β session,Β keyspace,Β ...])

aensure_db_setup()

Ensure that the DB setup is finished.

amdelete(keys)

Async delete the given keys and their associated values.

amget(keys)

Async get the values associated with the given keys.

amset(key_value_pairs)

Async set the values for the given keys.

ayield_keys(*[,Β prefix])

Async get an iterator over keys that match the given prefix.

ensure_db_setup()

Ensure that the DB setup is finished.

get_delete_statement()

Get the prepared delete statement for the table.

get_insert_statement()

Get the prepared insert statement for the table.

get_select_statement()

Get the prepared select statement for the table.

mdelete(keys)

Delete the given keys and their associated values.

mget(keys)

Get the values associated with the given keys.

mset(key_value_pairs)

Set the values for the given keys.

yield_keys(*[,Β prefix])

Get an iterator over keys that match the given prefix.

__init__(table: str, *, session: Session | None = None, keyspace: str | None = None, setup_mode: SetupMode = SetupMode.SYNC) β†’ None[source]#
Parameters:
  • table (str) –

  • session (Optional[Session]) –

  • keyspace (Optional[str]) –

  • setup_mode (SetupMode) –

Return type:

None

async aensure_db_setup() β†’ None[source]#

Ensure that the DB setup is finished. If not, wait for it.

Return type:

None

async amdelete(keys: Sequence[str]) β†’ None[source]#

Async delete the given keys and their associated values.

Parameters:

keys (Sequence[K]) – A sequence of keys to delete.

Return type:

None

async amget(keys: Sequence[str]) β†’ List[bytes | None][source]#

Async get the values associated with the given keys.

Parameters:

keys (Sequence[K]) – A sequence of keys.

Returns:

A sequence of optional values associated with the keys. If a key is not found, the corresponding value will be None.

Return type:

List[bytes | None]

async amset(key_value_pairs: Sequence[Tuple[str, bytes]]) β†’ None[source]#

Async set the values for the given keys.

Parameters:

key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.

Return type:

None

async ayield_keys(*, prefix: str | None = None) β†’ AsyncIterator[str][source]#

Async get an iterator over keys that match the given prefix.

Parameters:

prefix (str) – The prefix to match.

Yields:

Iterator[K | str] – An iterator over keys that match the given prefix. This method is allowed to return an iterator over either K or str depending on what makes more sense for the given store.

Return type:

AsyncIterator[str]

ensure_db_setup() β†’ None[source]#

Ensure that the DB setup is finished. If not, raise a ValueError.

Return type:

None

get_delete_statement() β†’ PreparedStatement[source]#

Get the prepared delete statement for the table. If not available, prepare it.

Returns:

The prepared statement.

Return type:

PreparedStatement

get_insert_statement() β†’ PreparedStatement[source]#

Get the prepared insert statement for the table. If not available, prepare it.

Returns:

The prepared statement.

Return type:

PreparedStatement

get_select_statement() β†’ PreparedStatement[source]#

Get the prepared select statement for the table. If not available, prepare it.

Returns:

The prepared statement.

Return type:

PreparedStatement

mdelete(keys: Sequence[str]) β†’ None[source]#

Delete the given keys and their associated values.

Parameters:

keys (Sequence[K]) – A sequence of keys to delete.

Return type:

None

mget(keys: Sequence[str]) β†’ List[bytes | None][source]#

Get the values associated with the given keys.

Parameters:

keys (Sequence[K]) – A sequence of keys.

Returns:

A sequence of optional values associated with the keys. If a key is not found, the corresponding value will be None.

Return type:

List[bytes | None]

mset(key_value_pairs: Sequence[Tuple[str, bytes]]) β†’ None[source]#

Set the values for the given keys.

Parameters:

key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.

Return type:

None

yield_keys(*, prefix: str | None = None) β†’ Iterator[str][source]#

Get an iterator over keys that match the given prefix.

Parameters:

prefix (str) – The prefix to match.

Yields:

Iterator[K | str] – An iterator over keys that match the given prefix. This method is allowed to return an iterator over either K or str depending on what makes more sense for the given store.

Return type:

Iterator[str]

Examples using CassandraByteStore