InMemoryRecordManager#
- class langchain_core.indexing.base.InMemoryRecordManager(namespace: str)[source]#
An in-memory record manager for testing purposes.
Initialize the in-memory record manager.
- Parameters:
namespace (str) – The namespace for the record manager.
Methods
__init__
(namespace)Initialize the in-memory record manager.
Async in-memory schema creation is simply ensuring the structure is initialized.
adelete_keys
(keys)Async delete specified records from the database.
aexists
(keys)Async check if the provided keys exist in the database.
Async get the current server time as a high resolution timestamp!
alist_keys
(*[, before, after, group_ids, limit])Async list records in the database based on the provided filters.
aupdate
(keys, *[, group_ids, time_at_least])Async upsert records into the database.
In-memory schema creation is simply ensuring the structure is initialized.
delete_keys
(keys)Delete specified records from the database.
exists
(keys)Check if the provided keys exist in the database.
get_time
()Get the current server time as a high resolution timestamp!
list_keys
(*[, before, after, group_ids, limit])List records in the database based on the provided filters.
update
(keys, *[, group_ids, time_at_least])Upsert records into the database.
- __init__(namespace: str) None [source]#
Initialize the in-memory record manager.
- Parameters:
namespace (str) – The namespace for the record manager.
- Return type:
None
- async acreate_schema() None [source]#
Async in-memory schema creation is simply ensuring the structure is initialized.
- Return type:
None
- async adelete_keys(keys: Sequence[str]) None [source]#
Async delete specified records from the database.
- Parameters:
keys (Sequence[str]) – A list of keys to delete.
- Return type:
None
- async aexists(keys: Sequence[str]) List[bool] [source]#
Async check if the provided keys exist in the database.
- Parameters:
keys (Sequence[str]) – A list of keys to check.
- Returns:
A list of boolean values indicating the existence of each key.
- Return type:
List[bool]
- async aget_time() float [source]#
Async get the current server time as a high resolution timestamp!
- Return type:
float
- async alist_keys(*, before: float | None = None, after: float | None = None, group_ids: Sequence[str] | None = None, limit: int | None = None) List[str] [source]#
Async list records in the database based on the provided filters.
- Parameters:
before (float | None) – Filter to list records updated before this time. Defaults to None.
after (float | None) – Filter to list records updated after this time. Defaults to None.
group_ids (Sequence[str] | None) – Filter to list records with specific group IDs. Defaults to None.
limit (int | None) – optional limit on the number of records to return. Defaults to None.
- Returns:
A list of keys for the matching records.
- Return type:
List[str]
- async aupdate(keys: Sequence[str], *, group_ids: Sequence[str | None] | None = None, time_at_least: float | None = None) None [source]#
Async upsert records into the database.
- Parameters:
keys (Sequence[str]) – A list of record keys to upsert.
group_ids (Sequence[str | None] | None) – A list of group IDs corresponding to the keys. Defaults to None.
time_at_least (float | None) – Optional timestamp. Implementation can use this to optionally verify that the timestamp IS at least this time in the system that stores. Defaults to None. E.g., use to validate that the time in the postgres database is equal to or larger than the given timestamp, if not raise an error. This is meant to help prevent time-drift issues since time may not be monotonically increasing!
- Raises:
ValueError – If the length of keys doesn’t match the length of group ids.
ValueError – If time_at_least is in the future.
- Return type:
None
- create_schema() None [source]#
In-memory schema creation is simply ensuring the structure is initialized.
- Return type:
None
- delete_keys(keys: Sequence[str]) None [source]#
Delete specified records from the database.
- Parameters:
keys (Sequence[str]) – A list of keys to delete.
- Return type:
None
- exists(keys: Sequence[str]) List[bool] [source]#
Check if the provided keys exist in the database.
- Parameters:
keys (Sequence[str]) – A list of keys to check.
- Returns:
A list of boolean values indicating the existence of each key.
- Return type:
List[bool]
- get_time() float [source]#
Get the current server time as a high resolution timestamp!
- Return type:
float
- list_keys(*, before: float | None = None, after: float | None = None, group_ids: Sequence[str] | None = None, limit: int | None = None) List[str] [source]#
List records in the database based on the provided filters.
- Parameters:
before (float | None) – Filter to list records updated before this time. Defaults to None.
after (float | None) – Filter to list records updated after this time. Defaults to None.
group_ids (Sequence[str] | None) – Filter to list records with specific group IDs. Defaults to None.
limit (int | None) – optional limit on the number of records to return. Defaults to None.
- Returns:
A list of keys for the matching records.
- Return type:
List[str]
- update(keys: Sequence[str], *, group_ids: Sequence[str | None] | None = None, time_at_least: float | None = None) None [source]#
Upsert records into the database.
- Parameters:
keys (Sequence[str]) – A list of record keys to upsert.
group_ids (Sequence[str | None] | None) – A list of group IDs corresponding to the keys. Defaults to None.
time_at_least (float | None) – Optional timestamp. Implementation can use this to optionally verify that the timestamp IS at least this time in the system that stores. Defaults to None. E.g., use to validate that the time in the postgres database is equal to or larger than the given timestamp, if not raise an error. This is meant to help prevent time-drift issues since time may not be monotonically increasing!
- Raises:
ValueError – If the length of keys doesn’t match the length of group ids.
ValueError – If time_at_least is in the future.
- Return type:
None