Skip to main content

Documentation Index

Fetch the complete documentation index at: https://nvd-54.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

概述

LangChain 提供了一个键值存储接口,用于按键存储和检索数据。 LangChain 中的键值存储接口主要用于缓存 embeddings.

接口

所有 BaseStores 支持以下接口:
  • mget(key: Sequence[str]) -> List[Optional[bytes]]: 获取多个键的内容,如果键不存在则返回 None
  • mset(key_value_pairs: Sequence[Tuple[str, bytes]]) -> None: 设置多个键的内容
  • mdelete(key: Sequence[str]) -> None: 删除多个键
  • yield_keys(prefix: Optional[str] = None) -> Iterator[str]: 迭代存储中的所有键,可选按前缀过滤
基础存储被设计为一次处理多个键值对以提高效率。 这减少了网络往返次数,并可能允许底层存储进行更高效的批量操作。

用于本地开发的内置存储

InMemoryByteStore

LocalFileStore

自定义存储

你也可以通过扩展 BaseStore 类来实现自定义存储。详见 store interface documentation

所有键值存储

AstraDBByteStore

CassandraByteStore

ElasticsearchEmbeddingsCache

RedisStore

UpstashRedisByteStore

BigtableByteStore