Class MemorystoreDocumentLoader (0.2.0)

MemorystoreDocumentLoader(
    client: redis.client.Redis,
    key_prefix: str,
    content_fields: typing.Set[str],
    metadata_fields: typing.Optional[typing.Set[str]] = None,
    batch_size: int = 100,
)

Document Loader for Cloud Memorystore for Redis database.

Methods

MemorystoreDocumentLoader

MemorystoreDocumentLoader(
    client: redis.client.Redis,
    key_prefix: str,
    content_fields: typing.Set[str],
    metadata_fields: typing.Optional[typing.Set[str]] = None,
    batch_size: int = 100,
)

Initializes the Document Loader for Memorystore for Redis.

Parameters
NameDescription
client Redis

A redis.Redis client object.

key_prefix str

A prefix for the keys to store Documents in Redis.

content_fields typing.Set[str]

The set of fields of the hash that Redis uses to store the page_content of the Document. If more than one field are specified, a JSON encoded dict containing the fields as top level keys will be filled in the page_content of the Documents.

metadata_fields typing.Optional[typing.Set[str]]

The metadata fields of the Document that will be stored in the Redis. If None, Redis stores all metadata fields.

batch_size int

Number of keys to load at once from Redis.

_construct_document

_construct_document(stored_value) -> langchain_core.documents.base.Document

Construct a Document from stored value.

_decode_if_json_parsable

_decode_if_json_parsable(s: str) -> typing.Union[str, dict]

Decode a JSON string to a dict if it is JSON.

lazy_load

lazy_load() -> typing.Iterator[langchain_core.documents.base.Document]

Lazy load the Documents and yield them one by one.

load

load() -> typing.List[langchain_core.documents.base.Document]

Load all Documents using a Redis pipeline for efficiency.