Skip to content

@codesoul-co/hypha-memory / managed-store

模块用法

用于持久化并读取该边界的数据。Managed store 模块公开 4 类、1 函数、8 接口。

从包入口导入

ts
import {
  InMemoryManagedMemoryRecordStore,
  InMemoryMemoryIdempotencyStore,
  InMemoryMemoryIndexOutboxStore,
  InMemoryMemoryPersistenceUnitOfWork,
  matchesFilter,
} from '@codesoul-co/hypha-memory';

import type {
  ManagedMemoryRecordQuery,
  ManagedMemoryRecordStore,
  MemoryIdempotencyStore,
  MemoryIndexOutboxRecord,
  MemoryIndexOutboxStore,
  MemoryPersistenceCapabilities,
  MemoryPersistenceTransaction,
  MemoryPersistenceUnitOfWork,
} from '@codesoul-co/hypha-memory';

使用要点

  • 8 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 4 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 1 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。

公共导出

Symbol种类签名说明
InMemoryManagedMemoryRecordStorenew InMemoryManagedMemoryRecordStore(): InMemoryManagedMemoryRecordStoreIn Memory Managed Memory Record Store 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryMemoryIdempotencyStorenew InMemoryMemoryIdempotencyStore(): InMemoryMemoryIdempotencyStoreIn Memory Memory Idempotency Store 类,共公开 3 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryMemoryIndexOutboxStorenew InMemoryMemoryIndexOutboxStore(): InMemoryMemoryIndexOutboxStoreIn Memory Memory Index Outbox Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。
InMemoryMemoryPersistenceUnitOfWorknew InMemoryMemoryPersistenceUnitOfWork(recordStore?: ManagedMemoryRecordStore, outboxStore?: MemoryIndexOutboxStore): InMemoryMemoryPersistenceUnitOfWorkIn Memory Memory Persistence Unit Of Work 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。
matchesFilter函数matchesFilter(record: ManagedMemoryRecord, filter?: MemorySearchFilter): booleanMatches Filter 函数,提供 1 个公开调用签名;参数与返回类型见下表。
ManagedMemoryRecordQuery接口interface ManagedMemoryRecordQueryManaged Memory Record Query 接口,共包含 5 个公开字段或方法。
ManagedMemoryRecordStore接口interface ManagedMemoryRecordStoreManaged Memory Record Store 接口,共包含 10 个公开字段或方法。
MemoryIdempotencyStore接口interface MemoryIdempotencyStoreMemory Idempotency Store 接口,共包含 2 个公开字段或方法。
MemoryIndexOutboxRecord接口interface MemoryIndexOutboxRecordMemory Index Outbox Record 接口,共包含 19 个公开字段或方法。
MemoryIndexOutboxStore接口interface MemoryIndexOutboxStoreMemory Index Outbox Store 接口,共包含 7 个公开字段或方法。
MemoryPersistenceCapabilities接口interface MemoryPersistenceCapabilitiesMemory Persistence Capabilities 接口,共包含 2 个公开字段或方法。
MemoryPersistenceTransaction接口interface MemoryPersistenceTransactionMemory Persistence Transaction 接口,共包含 2 个公开字段或方法。
MemoryPersistenceUnitOfWork接口interface MemoryPersistenceUnitOfWork extends MemoryPersistenceTransactionMemory Persistence Unit Of Work 接口,共包含 4 个公开字段或方法。

InMemoryManagedMemoryRecordStore

In Memory Managed Memory Record Store 类,共公开 11 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryManagedMemoryRecordStore } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export declare class InMemoryManagedMemoryRecordStore implements ManagedMemoryRecordStore {
    create(record: ManagedMemoryRecord): Promise<ManagedMemoryRecord>;
    get(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord | null>;
    getVersionByScopeHash(id: string, versionId: string, scopeHash: string): Promise<ManagedMemoryRecord | null>;
    list(request: ManagedMemoryRecordQuery): Promise<ManagedMemoryRecord[]>;
    createVersion(record: ManagedMemoryRecord, expectedRevision: number): Promise<ManagedMemoryRecord>;
    updateStatus(id: string, scope: ManagedMemoryScope, expectedRevision: number, status: MemoryStatus, updatedAt: string): Promise<ManagedMemoryRecord>;
    delete(id: string, scope: ManagedMemoryScope): Promise<void>;
    history(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord[]>;
    transaction<T>(fn: (store: ManagedMemoryRecordStore) => Promise<T>): Promise<T>;
    health(): Promise<ProviderHealth>;
}

公开成员

成员种类签名说明
constructor构造函数(): InMemoryManagedMemoryRecordStore创建该类的实例。
create方法create(record: ManagedMemoryRecord): Promise<ManagedMemoryRecord>公开方法;参数与返回类型以签名列为准。
createVersion方法createVersion(record: ManagedMemoryRecord, expectedRevision: number): Promise<ManagedMemoryRecord>公开方法;参数与返回类型以签名列为准。
delete方法delete(id: string, scope: ManagedMemoryScope): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord | null>公开方法;参数与返回类型以签名列为准。
getVersionByScopeHash方法getVersionByScopeHash(id: string, versionId: string, scopeHash: string): Promise<ManagedMemoryRecord | null>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
history方法history(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord[]>公开方法;参数与返回类型以签名列为准。
list方法list(request: ManagedMemoryRecordQuery): Promise<ManagedMemoryRecord[]>公开方法;参数与返回类型以签名列为准。
transaction方法transaction<T>(fn: (store: ManagedMemoryRecordStore) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。
updateStatus方法updateStatus(id: string, scope: ManagedMemoryScope, expectedRevision: number, status: MemoryStatus, updatedAt: string): Promise<ManagedMemoryRecord>公开方法;参数与返回类型以签名列为准。

InMemoryMemoryIdempotencyStore

In Memory Memory Idempotency Store 类,共公开 3 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryMemoryIdempotencyStore } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export declare class InMemoryMemoryIdempotencyStore implements MemoryIdempotencyStore {
    get(scopeHash: string, key: string): Promise<unknown | null>;
    set(scopeHash: string, key: string, result: unknown): Promise<void>;
}

公开成员

成员种类签名说明
constructor构造函数(): InMemoryMemoryIdempotencyStore创建该类的实例。
get方法get(scopeHash: string, key: string): Promise<unknown | null>公开方法;参数与返回类型以签名列为准。
set方法set(scopeHash: string, key: string, result: unknown): Promise<void>公开方法;参数与返回类型以签名列为准。

InMemoryMemoryIndexOutboxStore

In Memory Memory Index Outbox Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryMemoryIndexOutboxStore } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export declare class InMemoryMemoryIndexOutboxStore implements MemoryIndexOutboxStore {
    enqueue(record: MemoryIndexOutboxRecord): Promise<void>;
    lease(owner: string, now: string, leaseUntil: string, limit: number): Promise<MemoryIndexOutboxRecord[]>;
    renew(id: string, owner: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>;
    complete(id: string, owner: string, leaseToken: string, now: string): Promise<boolean>;
    fail(id: string, owner: string, leaseToken: string, now: string, error: import('./contracts').NormalizedMemoryError, retryAt: string, deadLetter?: boolean): Promise<boolean>;
    list(): Promise<MemoryIndexOutboxRecord[]>;
    transaction<T>(fn: (store: MemoryIndexOutboxStore) => Promise<T>): Promise<T>;
}

公开成员

成员种类签名说明
complete方法complete(id: string, owner: string, leaseToken: string, now: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
constructor构造函数(): InMemoryMemoryIndexOutboxStore创建该类的实例。
enqueue方法enqueue(record: MemoryIndexOutboxRecord): Promise<void>公开方法;参数与返回类型以签名列为准。
fail方法fail(id: string, owner: string, leaseToken: string, now: string, error: import("./contracts").NormalizedMemoryError, retryAt: string, deadLetter?: boolean): Promise<boolean>公开方法;参数与返回类型以签名列为准。
lease方法lease(owner: string, now: string, leaseUntil: string, limit: number): Promise<MemoryIndexOutboxRecord[]>公开方法;参数与返回类型以签名列为准。
list方法list(): Promise<MemoryIndexOutboxRecord[]>公开方法;参数与返回类型以签名列为准。
renew方法renew(id: string, owner: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
transaction方法transaction<T>(fn: (store: MemoryIndexOutboxStore) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。

InMemoryMemoryPersistenceUnitOfWork

In Memory Memory Persistence Unit Of Work 类,共公开 5 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { InMemoryMemoryPersistenceUnitOfWork } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export declare class InMemoryMemoryPersistenceUnitOfWork implements MemoryPersistenceUnitOfWork {
    readonly recordStore: ManagedMemoryRecordStore;
    readonly outboxStore: MemoryIndexOutboxStore;
    readonly capabilities: MemoryPersistenceCapabilities;
    constructor(recordStore?: ManagedMemoryRecordStore, outboxStore?: MemoryIndexOutboxStore);
    transaction<T>(fn: (stores: MemoryPersistenceTransaction) => Promise<T>): Promise<T>;
}

公开成员

成员种类签名说明
capabilities属性readonly capabilities: MemoryPersistenceCapabilities公开属性;类型、只读和可选状态以签名列为准。
constructor构造函数(recordStore?: ManagedMemoryRecordStore, outboxStore?: MemoryIndexOutboxStore): InMemoryMemoryPersistenceUnitOfWork创建该类的实例。
outboxStore属性readonly outboxStore: MemoryIndexOutboxStore公开属性;类型、只读和可选状态以签名列为准。
recordStore属性readonly recordStore: ManagedMemoryRecordStore公开属性;类型、只读和可选状态以签名列为准。
transaction方法transaction<T>(fn: (stores: MemoryPersistenceTransaction) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。

matchesFilter

Matches Filter 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { matchesFilter } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export declare function matchesFilter(record: ManagedMemoryRecord, filter?: MemorySearchFilter): boolean;

调用签名

text
matchesFilter(record: ManagedMemoryRecord, filter?: MemorySearchFilter): boolean

参数

参数类型必需说明
recordManagedMemoryRecord<unknown>必需参数;接受的值由类型列定义。
filterMemorySearchFilter可选参数;接受的值由类型列定义。

返回值

  • 类型: boolean
  • 说明: 返回值契约由上述类型定义。

ManagedMemoryRecordQuery

Managed Memory Record Query 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ManagedMemoryRecordQuery } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface ManagedMemoryRecordQuery {
    scope: ManagedMemoryScope;
    filter?: MemorySearchFilter;
    includeSuperseded?: boolean;
    includeInvalidated?: boolean;
    limit?: number;
}

契约成员

成员种类签名说明
filter属性filter?: MemorySearchFilter公开属性;类型、只读和可选状态以签名列为准。
includeInvalidated属性includeInvalidated?: boolean公开属性;类型、只读和可选状态以签名列为准。
includeSuperseded属性includeSuperseded?: boolean公开属性;类型、只读和可选状态以签名列为准。
limit属性limit?: number公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: ManagedMemoryScope公开属性;类型、只读和可选状态以签名列为准。

ManagedMemoryRecordStore

Managed Memory Record Store 接口,共包含 10 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ManagedMemoryRecordStore } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface ManagedMemoryRecordStore {
    create(record: ManagedMemoryRecord): Promise<ManagedMemoryRecord>;
    get(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord | null>;
    getVersionByScopeHash(id: string, versionId: string, scopeHash: string): Promise<ManagedMemoryRecord | null>;
    list(request: ManagedMemoryRecordQuery): Promise<ManagedMemoryRecord[]>;
    createVersion(record: ManagedMemoryRecord, expectedRevision: number): Promise<ManagedMemoryRecord>;
    updateStatus(id: string, scope: ManagedMemoryScope, expectedRevision: number, status: MemoryStatus, updatedAt: string): Promise<ManagedMemoryRecord>;
    delete(id: string, scope: ManagedMemoryScope): Promise<void>;
    history(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord[]>;
    transaction<T>(fn: (store: ManagedMemoryRecordStore) => Promise<T>): Promise<T>;
    health(): Promise<ProviderHealth>;
}

契约成员

成员种类签名说明
create方法create(record: ManagedMemoryRecord): Promise<ManagedMemoryRecord>公开方法;参数与返回类型以签名列为准。
createVersion方法createVersion(record: ManagedMemoryRecord, expectedRevision: number): Promise<ManagedMemoryRecord>公开方法;参数与返回类型以签名列为准。
delete方法delete(id: string, scope: ManagedMemoryScope): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord | null>公开方法;参数与返回类型以签名列为准。
getVersionByScopeHash方法getVersionByScopeHash(id: string, versionId: string, scopeHash: string): Promise<ManagedMemoryRecord | null>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
history方法history(id: string, scope: ManagedMemoryScope): Promise<ManagedMemoryRecord[]>公开方法;参数与返回类型以签名列为准。
list方法list(request: ManagedMemoryRecordQuery): Promise<ManagedMemoryRecord[]>公开方法;参数与返回类型以签名列为准。
transaction方法transaction<T>(fn: (store: ManagedMemoryRecordStore) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。
updateStatus方法updateStatus(id: string, scope: ManagedMemoryScope, expectedRevision: number, status: MemoryStatus, updatedAt: string): Promise<ManagedMemoryRecord>公开方法;参数与返回类型以签名列为准。

MemoryIdempotencyStore

Memory Idempotency Store 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryIdempotencyStore } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface MemoryIdempotencyStore {
    get(scopeHash: string, key: string): Promise<unknown | null>;
    set(scopeHash: string, key: string, result: unknown): Promise<void>;
}

契约成员

成员种类签名说明
get方法get(scopeHash: string, key: string): Promise<unknown | null>公开方法;参数与返回类型以签名列为准。
set方法set(scopeHash: string, key: string, result: unknown): Promise<void>公开方法;参数与返回类型以签名列为准。

MemoryIndexOutboxRecord

Memory Index Outbox Record 接口,共包含 19 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryIndexOutboxRecord } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface MemoryIndexOutboxRecord {
    id: string;
    operationId: string;
    memoryId: string;
    memoryVersionId: string;
    /** Logical Memory revision; distinct from this outbox record's lease fencing token. */
    memoryRevision?: number;
    scopeHash: string;
    action: 'upsert' | 'delete' | 'reindex';
    targetVectorStoreIds: string[];
    state: 'pending' | 'processing' | 'completed' | 'partial' | 'failed' | 'dead_letter';
    attempts: number;
    availableAt: string;
    completedVectorStoreIds?: string[];
    leaseOwner?: string;
    leaseToken?: string;
    leaseExpiresAt?: string;
    fencingToken?: number;
    lastError?: import('./contracts').NormalizedMemoryError;
    createdAt: string;
    updatedAt: string;
}

契约成员

成员种类签名说明
action属性action: "delete" | "reindex" | "upsert"公开属性;类型、只读和可选状态以签名列为准。
attempts属性attempts: number公开属性;类型、只读和可选状态以签名列为准。
availableAt属性availableAt: string公开属性;类型、只读和可选状态以签名列为准。
completedVectorStoreIds属性completedVectorStoreIds?: string[]公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
fencingToken属性fencingToken?: number公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
lastError属性lastError?: import("/Users/erwin/Downloads/codespace/Hypha/packages/memory/dist/contracts").NormalizedMemoryError公开属性;类型、只读和可选状态以签名列为准。
leaseExpiresAt属性leaseExpiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
leaseOwner属性leaseOwner?: string公开属性;类型、只读和可选状态以签名列为准。
leaseToken属性leaseToken?: string公开属性;类型、只读和可选状态以签名列为准。
memoryId属性memoryId: string公开属性;类型、只读和可选状态以签名列为准。
memoryRevision属性memoryRevision?: numberLogical Memory revision; distinct from this outbox record's lease fencing token.
memoryVersionId属性memoryVersionId: string公开属性;类型、只读和可选状态以签名列为准。
operationId属性operationId: string公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
state属性state: "completed" | "failed" | "processing" | "pending" | "dead_letter" | "partial"公开属性;类型、只读和可选状态以签名列为准。
targetVectorStoreIds属性targetVectorStoreIds: string[]公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt: string公开属性;类型、只读和可选状态以签名列为准。

MemoryIndexOutboxStore

Memory Index Outbox Store 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryIndexOutboxStore } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface MemoryIndexOutboxStore {
    enqueue(record: MemoryIndexOutboxRecord): Promise<void>;
    lease(owner: string, now: string, leaseUntil: string, limit: number): Promise<MemoryIndexOutboxRecord[]>;
    renew(id: string, owner: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>;
    complete(id: string, owner: string, leaseToken: string, now: string): Promise<boolean>;
    fail(id: string, owner: string, leaseToken: string, now: string, error: import('./contracts').NormalizedMemoryError, retryAt: string, deadLetter?: boolean): Promise<boolean>;
    list(): Promise<MemoryIndexOutboxRecord[]>;
    transaction<T>(fn: (store: MemoryIndexOutboxStore) => Promise<T>): Promise<T>;
}

契约成员

成员种类签名说明
complete方法complete(id: string, owner: string, leaseToken: string, now: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
enqueue方法enqueue(record: MemoryIndexOutboxRecord): Promise<void>公开方法;参数与返回类型以签名列为准。
fail方法fail(id: string, owner: string, leaseToken: string, now: string, error: import("./contracts").NormalizedMemoryError, retryAt: string, deadLetter?: boolean): Promise<boolean>公开方法;参数与返回类型以签名列为准。
lease方法lease(owner: string, now: string, leaseUntil: string, limit: number): Promise<MemoryIndexOutboxRecord[]>公开方法;参数与返回类型以签名列为准。
list方法list(): Promise<MemoryIndexOutboxRecord[]>公开方法;参数与返回类型以签名列为准。
renew方法renew(id: string, owner: string, leaseToken: string, now: string, leaseUntil: string): Promise<boolean>公开方法;参数与返回类型以签名列为准。
transaction方法transaction<T>(fn: (store: MemoryIndexOutboxStore) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。

MemoryPersistenceCapabilities

Memory Persistence Capabilities 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryPersistenceCapabilities } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface MemoryPersistenceCapabilities {
    durable: boolean;
    atomicRecordAndOutbox: boolean;
}

契约成员

成员种类签名说明
atomicRecordAndOutbox属性atomicRecordAndOutbox: boolean公开属性;类型、只读和可选状态以签名列为准。
durable属性durable: boolean公开属性;类型、只读和可选状态以签名列为准。

MemoryPersistenceTransaction

Memory Persistence Transaction 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryPersistenceTransaction } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface MemoryPersistenceTransaction {
    recordStore: ManagedMemoryRecordStore;
    outboxStore: MemoryIndexOutboxStore;
}

契约成员

成员种类签名说明
outboxStore属性outboxStore: MemoryIndexOutboxStore公开属性;类型、只读和可选状态以签名列为准。
recordStore属性recordStore: ManagedMemoryRecordStore公开属性;类型、只读和可选状态以签名列为准。

MemoryPersistenceUnitOfWork

Memory Persistence Unit Of Work 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { MemoryPersistenceUnitOfWork } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-store

声明

text
export interface MemoryPersistenceUnitOfWork extends MemoryPersistenceTransaction {
    capabilities: MemoryPersistenceCapabilities;
    transaction<T>(fn: (stores: MemoryPersistenceTransaction) => Promise<T>): Promise<T>;
}

契约成员

成员种类签名说明
capabilities属性capabilities: MemoryPersistenceCapabilities公开属性;类型、只读和可选状态以签名列为准。
outboxStore属性outboxStore: MemoryIndexOutboxStore公开属性;类型、只读和可选状态以签名列为准。
recordStore属性recordStore: ManagedMemoryRecordStore公开属性;类型、只读和可选状态以签名列为准。
transaction方法transaction<T>(fn: (stores: MemoryPersistenceTransaction) => Promise<T>): Promise<T>公开方法;参数与返回类型以签名列为准。