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,Β ...])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 that the DB setup is finished.
Get the prepared delete statement for the table.
Get the prepared insert statement for the table.
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