已弃用

InMemoryStore 的别名

继承关系 (查看完整)

构造函数

访问器

  • get indexConfig(): undefined | IndexConfig
  • 返回值 undefined | IndexConfig

方法

  • 在单个批次中执行多个操作。这比单独执行操作更有效。

    类型参数

    参数

    • operations: Op

      要执行的操作数组

    返回值 Promise<OperationResults<Op>>

    解析为与操作匹配的结果的 Promise

  • 从存储中删除一个项目。

    参数

    • namespace: string[]

      项目的层级路径

    • key: string

      命名空间内的唯一标识符

    返回值 Promise<void>

  • 通过其命名空间和键检索单个项目。

    参数

    • namespace: string[]

      项目的层级路径

    • key: string

      命名空间内的唯一标识符

    返回值 Promise<null | Item>

    解析为项目或 null(如果未找到)的 Promise

  • 列出和过滤存储中的命名空间。用于探索数据组织和导航命名空间层次结构。

    参数

    • Optional options: {
          limit?: number;
          maxDepth?: number;
          offset?: number;
          prefix?: string[];
          suffix?: string[];
      }

      列出命名空间的选项

      • Optional limit?: number
      • Optional maxDepth?: number
      • Optional offset?: number
      • Optional prefix?: string[]
      • Optional suffix?: string[]

    返回值 Promise<string[][]>

    解析为命名空间路径列表的 Promise

    示例

    // List all namespaces under "documents"
    await store.listNamespaces({
    prefix: ["documents"],
    maxDepth: 2
    });

    // List namespaces ending with "v1"
    await store.listNamespaces({
    suffix: ["v1"],
    limit: 50
    });
  • 存储或更新一个项目。

    参数

    • namespace: string[]

      项目的层级路径

    • key: string

      命名空间内的唯一标识符

    • value: Record<string, any>

      包含项目数据的对象

    • Optional index: false | string[]

      可选的索引配置

    返回值 Promise<void>

    示例

    // Simple storage
    await store.put(["docs"], "report", { title: "Annual Report" });

    // With specific field indexing
    await store.put(
    ["docs"],
    "report",
    {
    title: "Q4 Report",
    chapters: [{ content: "..." }, { content: "..." }]
    },
    ["title", "chapters[*].content"]
    );
  • 在命名空间前缀内搜索项目。支持元数据过滤和向量相似度搜索。

    参数

    • namespacePrefix: string[]

      要在其中搜索的层级路径前缀

    • Optional options: {
          filter?: Record<string, any>;
          limit?: number;
          offset?: number;
          query?: string;
      }

      用于过滤和分页的搜索选项

      • Optional filter?: Record<string, any>
      • Optional limit?: number
      • Optional offset?: number
      • Optional query?: string

    返回值 Promise<SearchItem[]>

    解析为具有相关性分数的匹配项目列表的 Promise

    示例

    // Search with filters
    await store.search(["documents"], {
    filter: { type: "report", status: "active" },
    limit: 5,
    offset: 10
    });

    // Vector similarity search
    await store.search(["users", "content"], {
    query: "technical documentation about APIs",
    limit: 20
    });
  • 启动存储。如果需要初始化,请覆盖。

    返回值 void

  • 停止存储。如果需要清理,请覆盖。

    返回值 void