Skip to content

@codesoul-co/hypha-memory / managed-search-cache

模块用法

用于读写或协调缓存状态。Managed search cache 模块公开 3 类、2 常量、3 函数、8 接口、4 类型。

从包入口导入

ts
import {
  CachedMemoryManagementProvider,
  InMemoryMemorySearchCacheStore,
  RedisMemorySearchCacheStore,
  managedMemorySearchResultSchema,
  memorySearchCacheRecordSchema,
  composeMemorySearchCacheProvider,
  validateManagedMemorySearchResults,
  validateMemorySearchCacheRecord,
} from '@codesoul-co/hypha-memory';

import type {
  CachedMemoryManagementProviderOptions,
  InMemoryMemorySearchCacheOptions,
  MemorySearchCacheAuthorizationDecision,
  MemorySearchCacheAuthorizationPort,
  MemorySearchCacheEvent,
  MemorySearchCacheStore,
  RedisLikeMemorySearchCacheClient,
  RedisMemorySearchCacheOptions,
} from '@codesoul-co/hypha-memory';

// 完整导出列表见下方。

使用要点

  • 12 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 3 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 3 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
  • 2 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

ts
import { managedMemorySearchResultSchema } from '@codesoul-co/hypha-memory';

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = managedMemorySearchResultSchema.parse(input);

配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。

公共导出

Symbol种类签名说明
CachedMemoryManagementProvidernew CachedMemoryManagementProvider(options: CachedMemoryManagementProviderOptions): CachedMemoryManagementProviderManaged-memory read-through cache. Mutations always execute against the provider first and then invalidate the exact scope. Access-stat searches are never cached because a hit would skip their intended write side effect.
InMemoryMemorySearchCacheStorenew InMemoryMemorySearchCacheStore(options?: InMemoryMemorySearchCacheOptions): InMemoryMemorySearchCacheStoreIn Memory Memory Search Cache Store 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。
RedisMemorySearchCacheStorenew RedisMemorySearchCacheStore(options: RedisMemorySearchCacheOptions): RedisMemorySearchCacheStoreShared Store for local, self-hosted, or managed Redis-compatible deployments.
managedMemorySearchResultSchema常量const managedMemorySearchResultSchema: z.ZodObject<{ record: z.ZodEffects<z.ZodObject<{ id: z.ZodString; versionId: z.ZodString; revision: z.ZodNumber; type: z.ZodEnum<["working", "episodic", "semantic", "procedural", "preference", "artifact", "governance", "reflection", "custom"]>; subtype: z.ZodOptional<z.ZodString>; content: z.ZodUnknown; canonicalText: z.ZodOptional<z.ZodString>; summary: z.ZodOptional<z.ZodSt...Managed Memory Search Result 的运行时 Schema。
memorySearchCacheRecordSchema常量const memorySearchCacheRecordSchema: z.ZodEffects<z.ZodObject<{ schemaVersion: z.ZodLiteral<"1.0">; keyVersion: z.ZodLiteral<"1">; key: z.ZodString; scopeHash: z.ZodString; scopeRevision: z.ZodString; requestHash: z.ZodString; profileRevision: z.ZodString; providerRevision: z.ZodString; results: z.ZodArray<z.ZodObject<{ record: z.ZodEffects<z.ZodObject<{ id: z.ZodString; versionId: z.ZodString; revision: z.ZodNumb...Memory Search Cache Record 的运行时 Schema。
composeMemorySearchCacheProvider函数composeMemorySearchCacheProvider(options: MemorySearchCacheCompositionOptions): MemoryManagementProviderExplicit product-composition boundary for Search Cache mode. Disabled mode returns the canonical provider without opening or consulting a Cache Store.
validateManagedMemorySearchResults函数validateManagedMemorySearchResults(input: unknown): ManagedMemorySearchResult[]Validate Managed Memory Search Results 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateMemorySearchCacheRecord函数validateMemorySearchCacheRecord(input: unknown, maxEntryBytes?: number): MemorySearchCacheRecordValidate Memory Search Cache Record 函数,提供 1 个公开调用签名;参数与返回类型见下表。
CachedMemoryManagementProviderOptions接口interface CachedMemoryManagementProviderOptionsCached Memory Management Provider Options 接口,共包含 14 个公开字段或方法。
InMemoryMemorySearchCacheOptions接口interface InMemoryMemorySearchCacheOptionsIn Memory Memory Search Cache Options 接口,共包含 2 个公开字段或方法。
MemorySearchCacheAuthorizationDecision接口interface MemorySearchCacheAuthorizationDecisionMemory Search Cache Authorization Decision 接口,共包含 4 个公开字段或方法。
MemorySearchCacheAuthorizationPort接口interface MemorySearchCacheAuthorizationPortMemory Search Cache Authorization Port 接口,共包含 1 个公开字段或方法。
MemorySearchCacheEvent接口interface MemorySearchCacheEventMemory Search Cache Event 接口,共包含 6 个公开字段或方法。
MemorySearchCacheStore接口interface MemorySearchCacheStoreMemory Search Cache Store 接口,共包含 7 个公开字段或方法。
RedisLikeMemorySearchCacheClient接口interface RedisLikeMemorySearchCacheClientRedis Like Memory Search Cache Client 接口,共包含 8 个公开字段或方法。
RedisMemorySearchCacheOptions接口interface RedisMemorySearchCacheOptionsRedis Memory Search Cache Options 接口,共包含 4 个公开字段或方法。
MemorySearchCacheCompositionOptions类型type MemorySearchCacheCompositionOptions = { mode: 'disabled'; provider: MemoryManagementProvider; } | (CachedMemoryManagementProviderOptions & { mode: 'enabled'; })Memory Search Cache Composition Options 公共类型别名;完整类型表达式见声明。
MemorySearchCacheFailureMode类型type MemorySearchCacheFailureMode = 'bypass' | 'strict'Memory Search Cache Failure Mode 公共类型别名;完整类型表达式见声明。
MemorySearchCacheMode类型type MemorySearchCacheMode = 'enabled' | 'disabled'Memory Search Cache Mode 公共类型别名;完整类型表达式见声明。
MemorySearchCacheRecord类型type MemorySearchCacheRecord = z.infer<typeof memorySearchCacheRecordSchema>Memory Search Cache Record 公共类型别名;完整类型表达式见声明。

CachedMemoryManagementProvider

Managed-memory read-through cache. Mutations always execute against the provider first and then invalidate the exact scope. Access-stat searches are never cached because a hit would skip their intended write side effect.

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

声明

text
export declare class CachedMemoryManagementProvider implements MemoryManagementProvider {
    readonly id: string;
    constructor(options: CachedMemoryManagementProviderOptions);
    capabilities(): Promise<import("./contracts").MemoryManagementCapabilities>;
    add(request: MemoryAddRequest): Promise<ManagedMemoryWriteResult>;
    search(rawRequest: ManagedMemorySearchRequest): Promise<ManagedMemorySearchResult[]>;
    get(request: MemoryGetRequest): Promise<import("./contracts").ManagedMemoryRecord<unknown> | null>;
    list(request: MemoryListRequest): Promise<MemoryListResult>;
    update(request: ManagedMemoryUpdateRequest): Promise<ManagedMemoryWriteResult>;
    delete(request: ManagedMemoryDeleteRequest): Promise<ManagedMemoryDeleteResult>;
    history(request: MemoryHistoryRequest): Promise<MemoryVersion[]>;
    health(): Promise<ProviderHealth>;
    close(): Promise<void>;
}

公开成员

成员种类签名说明
add方法add(request: MemoryAddRequest): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。
capabilities方法capabilities(): Promise<import("./contracts").MemoryManagementCapabilities>公开方法;参数与返回类型以签名列为准。
close方法close(): Promise<void>公开方法;参数与返回类型以签名列为准。
constructor构造函数(options: CachedMemoryManagementProviderOptions): CachedMemoryManagementProvider创建该类的实例。
delete方法delete(request: ManagedMemoryDeleteRequest): Promise<ManagedMemoryDeleteResult>公开方法;参数与返回类型以签名列为准。
get方法get(request: MemoryGetRequest): Promise<import("./contracts").ManagedMemoryRecord<unknown> | null>公开方法;参数与返回类型以签名列为准。
health方法health(): Promise<ProviderHealth>公开方法;参数与返回类型以签名列为准。
history方法history(request: MemoryHistoryRequest): Promise<MemoryVersion[]>公开方法;参数与返回类型以签名列为准。
id属性readonly id: string公开属性;类型、只读和可选状态以签名列为准。
list方法list(request: MemoryListRequest): Promise<MemoryListResult>公开方法;参数与返回类型以签名列为准。
search方法search(rawRequest: ManagedMemorySearchRequest): Promise<ManagedMemorySearchResult[]>公开方法;参数与返回类型以签名列为准。
update方法update(request: ManagedMemoryUpdateRequest): Promise<ManagedMemoryWriteResult>公开方法;参数与返回类型以签名列为准。

InMemoryMemorySearchCacheStore

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

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

声明

text
export declare class InMemoryMemorySearchCacheStore implements MemorySearchCacheStore {
    constructor(options?: InMemoryMemorySearchCacheOptions);
    getScopeRevision(scopeHash: string): Promise<string>;
    get(key: string): Promise<MemorySearchCacheRecord | null>;
    set(key: string, rawRecord: MemorySearchCacheRecord): Promise<void>;
    delete(key: string): Promise<void>;
    invalidateScope(scopeHash: string): Promise<number>;
    clear(): Promise<void>;
    stats(): {
            entries: number;
            sizeBytes: number;
            evictions: number;
        };
}

公开成员

成员种类签名说明
clear方法clear(): Promise<void>公开方法;参数与返回类型以签名列为准。
constructor构造函数(options?: InMemoryMemorySearchCacheOptions): InMemoryMemorySearchCacheStore创建该类的实例。
delete方法delete(key: string): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<MemorySearchCacheRecord | null>公开方法;参数与返回类型以签名列为准。
getScopeRevision方法getScopeRevision(scopeHash: string): Promise<string>公开方法;参数与返回类型以签名列为准。
invalidateScope方法invalidateScope(scopeHash: string): Promise<number>公开方法;参数与返回类型以签名列为准。
set方法set(key: string, rawRecord: MemorySearchCacheRecord): Promise<void>公开方法;参数与返回类型以签名列为准。
stats方法stats(): { entries: number; sizeBytes: number; evictions: number; }公开方法;参数与返回类型以签名列为准。

RedisMemorySearchCacheStore

Shared Store for local, self-hosted, or managed Redis-compatible deployments.

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

声明

text
export declare class RedisMemorySearchCacheStore implements MemorySearchCacheStore {
    constructor(options: RedisMemorySearchCacheOptions);
    getScopeRevision(scopeHash: string): Promise<string>;
    get(key: string): Promise<MemorySearchCacheRecord | null>;
    set(key: string, input: MemorySearchCacheRecord): Promise<void>;
    delete(key: string): Promise<void>;
    invalidateScope(scopeHash: string): Promise<number>;
}

公开成员

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

managedMemorySearchResultSchema

Managed Memory Search Result 的运行时 Schema。

  • 种类: 常量
  • 导入: import { managedMemorySearchResultSchema } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-search-cache

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const managedMemorySearchResultSchema: (typeof import('@codesoul-co/hypha-memory'))['managedMemorySearchResultSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

memorySearchCacheRecordSchema

Memory Search Cache Record 的运行时 Schema。

  • 种类: 常量
  • 导入: import { memorySearchCacheRecordSchema } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-search-cache

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const memorySearchCacheRecordSchema: (typeof import('@codesoul-co/hypha-memory'))['memorySearchCacheRecordSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

composeMemorySearchCacheProvider

Explicit product-composition boundary for Search Cache mode. Disabled mode returns the canonical provider without opening or consulting a Cache Store.

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

声明

text
export declare function composeMemorySearchCacheProvider(options: MemorySearchCacheCompositionOptions): MemoryManagementProvider;

调用签名

text
composeMemorySearchCacheProvider(options: MemorySearchCacheCompositionOptions): MemoryManagementProvider

Explicit product-composition boundary for Search Cache mode. Disabled mode returns the canonical provider without opening or consulting a Cache Store.

参数

参数类型必需说明
optionsMemorySearchCacheCompositionOptions必需参数;接受的值由类型列定义。

返回值

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

validateManagedMemorySearchResults

Validate Managed Memory Search Results 函数,提供 1 个公开调用签名;参数与返回类型见下表。

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

声明

text
export declare function validateManagedMemorySearchResults(input: unknown): ManagedMemorySearchResult[];

调用签名

text
validateManagedMemorySearchResults(input: unknown): ManagedMemorySearchResult[]

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

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

validateMemorySearchCacheRecord

Validate Memory Search Cache Record 函数,提供 1 个公开调用签名;参数与返回类型见下表。

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

声明

text
export declare function validateMemorySearchCacheRecord(input: unknown, maxEntryBytes?: number): MemorySearchCacheRecord;

调用签名

text
validateMemorySearchCacheRecord(input: unknown, maxEntryBytes?: number): MemorySearchCacheRecord

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。
maxEntryBytesnumber可选参数;接受的值由类型列定义。

返回值

  • 类型: { createdAt: number; scopeHash: string; expiresAt: number; providerRevision: string; profileRevision: string; key: string; schemaVersion: "1.0"; keyVersion: "1"; scopeRevision: string; requestHash: string; results: { record: { id: string; type: "working" | "episodic" | "semantic" | "procedural" | "artifact" | "governance" | "custom" | "preference" | "reflection"; status: "pending" | "failed" | "deleted" | "active" | "dormant" | "superseded" | "invalidated" | "deletion_pending"; createdAt: string; updatedAt: string; revision: number; scopeHash: string; scope: { userId: string; workspaceId?: string | undefined; sessionId?: string | undefined; runId?: string | undefined; tenantId?: string | undefined; projectId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; source: { type: "artifact" | "human_review" | "user_message" | "assistant_message" | "tool_result" | "workflow_state" | "import" | "derived" | "system"; sourceId?: string | undefined; sourceEventId?: string | undefined; sourceRunId?: string | undefined; sourceMessageId?: string | undefined; sourceArtifactId?: string | undefined; }; visibility: "workspace" | "private" | "session" | "tenant" | "shared"; provenance: { createdAt: string; providerId: string; createdBy: string; metadata?: Record<string, unknown> | undefined; extractorVersion?: string | undefined; sourceEventIds?: string[] | undefined; sourceMemoryIds?: string[] | undefined; transformation?: string | undefined; humanDecisionId?: string | undefined; }; versionId: string; contentHash: string; accessCount: number; indexStatus: { state: "none" | "pending" | "failed" | "deleted" | "partial" | "indexing" | "indexed"; attempts: number; lastError?: import("./contracts").NormalizedMemoryError | undefined; lastAttemptAt?: string | undefined; }; tags?: string[] | undefined; metadata?: Record<string, unknown> | undefined; expiresAt?: string | undefined; confidence?: number | undefined; entities?: { entityId: string; type?: string | undefined; confidence?: number | undefined; label?: string | undefined; }[] | undefined; canonicalText?: string | undefined; content?: unknown; importance?: number | undefined; subtype?: string | undefined; summary?: string | undefined; language?: string | undefined; strength?: number | undefined; salience?: number | undefined; lastAccessedAt?: string | undefined; lastReinforcedAt?: string | undefined; decayScore?: number | undefined; immutable?: boolean | undefined; humanVerified?: boolean | undefined; sensitive?: boolean | undefined; relations?: { type: "supersedes" | "supports" | "contradicts" | "derived_from" | "related_to" | "same_as" | "part_of"; targetMemoryId: string; metadata?: Record<string, unknown> | undefined; confidence?: number | undefined; }[] | undefined; vectorRefs?: { vectorStoreId: string; indexName: string; vectorId: string; embeddingProviderId: string; embeddingModel: string; indexedAt: string; embeddingRevision?: string | undefined; dimensions?: number | undefined; }[] | undefined; artifactRefs?: string[] | undefined; deletedAt?: string | undefined; }; score?: number | undefined; semanticScore?: number | undefined; keywordScore?: number | undefined; graphScore?: number | undefined; rerankScore?: number | undefined; reasons?: string[] | undefined; }[]; selectedMemoryVersionIds: string[]; sizeBytes?: number | undefined; }
  • 说明: 返回值契约由上述类型定义。

CachedMemoryManagementProviderOptions

Cached Memory Management Provider Options 接口,共包含 14 个公开字段或方法。

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

声明

text
export interface CachedMemoryManagementProviderOptions {
    provider: MemoryManagementProvider;
    cache: MemorySearchCacheStore;
    providerRevision: string;
    failureMode?: MemorySearchCacheFailureMode;
    operationTimeoutMs?: number;
    ttlMs?: number;
    maxEntryBytes?: number;
    singleflight?: boolean;
    maxScopeRevisionRetries?: number;
    requiredScopeFields?: readonly (keyof ManagedMemoryScope)[];
    cacheAuthorization?: MemorySearchCacheAuthorizationPort;
    requireCacheAuthorization?: boolean;
    now?: () => number;
    trace?: (event: MemorySearchCacheEvent) => Promise<void> | void;
}

契约成员

成员种类签名说明
cache属性cache: MemorySearchCacheStore公开属性;类型、只读和可选状态以签名列为准。
cacheAuthorization属性cacheAuthorization?: MemorySearchCacheAuthorizationPort公开属性;类型、只读和可选状态以签名列为准。
failureMode属性failureMode?: MemorySearchCacheFailureMode公开属性;类型、只读和可选状态以签名列为准。
maxEntryBytes属性maxEntryBytes?: number公开属性;类型、只读和可选状态以签名列为准。
maxScopeRevisionRetries属性maxScopeRevisionRetries?: number公开属性;类型、只读和可选状态以签名列为准。
now方法now?(): number公开方法;参数与返回类型以签名列为准。
operationTimeoutMs属性operationTimeoutMs?: number公开属性;类型、只读和可选状态以签名列为准。
provider属性provider: MemoryManagementProvider公开属性;类型、只读和可选状态以签名列为准。
providerRevision属性providerRevision: string公开属性;类型、只读和可选状态以签名列为准。
requireCacheAuthorization属性requireCacheAuthorization?: boolean公开属性;类型、只读和可选状态以签名列为准。
requiredScopeFields属性requiredScopeFields?: readonly (keyof ManagedMemoryScope)[]公开属性;类型、只读和可选状态以签名列为准。
singleflight属性singleflight?: boolean公开属性;类型、只读和可选状态以签名列为准。
trace方法trace?(event: MemorySearchCacheEvent): Promise<void> | void公开方法;参数与返回类型以签名列为准。
ttlMs属性ttlMs?: number公开属性;类型、只读和可选状态以签名列为准。

InMemoryMemorySearchCacheOptions

In Memory Memory Search Cache Options 接口,共包含 2 个公开字段或方法。

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

声明

text
export interface InMemoryMemorySearchCacheOptions {
    maxEntries?: number;
    maxBytes?: number;
}

契约成员

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

MemorySearchCacheAuthorizationDecision

Memory Search Cache Authorization Decision 接口,共包含 4 个公开字段或方法。

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

声明

text
export interface MemorySearchCacheAuthorizationDecision {
    allowed: boolean;
    policyRevision: string;
    expiresAt?: string;
    reason?: string;
}

契约成员

成员种类签名说明
allowed属性allowed: boolean公开属性;类型、只读和可选状态以签名列为准。
expiresAt属性expiresAt?: string公开属性;类型、只读和可选状态以签名列为准。
policyRevision属性policyRevision: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。

MemorySearchCacheAuthorizationPort

Memory Search Cache Authorization Port 接口,共包含 1 个公开字段或方法。

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

声明

text
export interface MemorySearchCacheAuthorizationPort {
    authorize(request: ManagedMemorySearchRequest): Promise<MemorySearchCacheAuthorizationDecision>;
}

契约成员

成员种类签名说明
authorize方法authorize(request: ManagedMemorySearchRequest): Promise<MemorySearchCacheAuthorizationDecision>公开方法;参数与返回类型以签名列为准。

MemorySearchCacheEvent

Memory Search Cache Event 接口,共包含 6 个公开字段或方法。

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

声明

text
export interface MemorySearchCacheEvent {
    type: 'memory.cache.lookup' | 'memory.cache.hit' | 'memory.cache.miss' | 'memory.cache.write' | 'memory.cache.invalidate' | 'memory.cache.bypass';
    providerId: string;
    scopeHash: string;
    key?: string;
    reason?: 'not_found' | 'expired' | 'corrupt' | 'scope_mismatch' | 'revision_changed' | 'access_stats_requested' | 'profile_revision_missing' | 'scope_incomplete' | 'invalidation_pending' | 'entry_oversized' | 'store_unavailable';
    ageMs?: number;
}

契约成员

成员种类签名说明
ageMs属性ageMs?: number公开属性;类型、只读和可选状态以签名列为准。
key属性key?: string公开属性;类型、只读和可选状态以签名列为准。
providerId属性providerId: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: "not_found" | "expired" | "scope_mismatch" | "store_unavailable" | "entry_oversized" | "corrupt" | "revision_changed" | "access_stats_requested" | "profile_revision_missing" | "scope_incomplete" | "invalidation_pending"公开属性;类型、只读和可选状态以签名列为准。
scopeHash属性scopeHash: string公开属性;类型、只读和可选状态以签名列为准。
type属性type: "memory.cache.lookup" | "memory.cache.hit" | "memory.cache.miss" | "memory.cache.write" | "memory.cache.invalidate" | "memory.cache.bypass"公开属性;类型、只读和可选状态以签名列为准。

MemorySearchCacheStore

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

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

声明

text
export interface MemorySearchCacheStore {
    getScopeRevision(scopeHash: string): Promise<string>;
    get(key: string): Promise<MemorySearchCacheRecord | null>;
    set(key: string, record: MemorySearchCacheRecord): Promise<void>;
    delete(key: string): Promise<void>;
    invalidateScope(scopeHash: string): Promise<number>;
    clear?(): Promise<void>;
    close?(): Promise<void>;
}

契约成员

成员种类签名说明
clear方法clear?(): Promise<void>公开方法;参数与返回类型以签名列为准。
close方法close?(): Promise<void>公开方法;参数与返回类型以签名列为准。
delete方法delete(key: string): Promise<void>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<MemorySearchCacheRecord | null>公开方法;参数与返回类型以签名列为准。
getScopeRevision方法getScopeRevision(scopeHash: string): Promise<string>公开方法;参数与返回类型以签名列为准。
invalidateScope方法invalidateScope(scopeHash: string): Promise<number>公开方法;参数与返回类型以签名列为准。
set方法set(key: string, record: MemorySearchCacheRecord): Promise<void>公开方法;参数与返回类型以签名列为准。

RedisLikeMemorySearchCacheClient

Redis Like Memory Search Cache Client 接口,共包含 8 个公开字段或方法。

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

声明

text
export interface RedisLikeMemorySearchCacheClient {
    get(key: string): Promise<string | null>;
    set(key: string, value: string, mode: 'PX', durationMilliseconds: number): Promise<unknown>;
    del(...keys: string[]): Promise<number>;
    sadd(key: string, ...members: string[]): Promise<number>;
    srem(key: string, ...members: string[]): Promise<number>;
    smembers(key: string): Promise<string[]>;
    incr(key: string): Promise<number>;
    pexpire(key: string, durationMilliseconds: number): Promise<number>;
}

契约成员

成员种类签名说明
del方法del(...keys: string[]): Promise<number>公开方法;参数与返回类型以签名列为准。
get方法get(key: string): Promise<string | null>公开方法;参数与返回类型以签名列为准。
incr方法incr(key: string): Promise<number>公开方法;参数与返回类型以签名列为准。
pexpire方法pexpire(key: string, durationMilliseconds: number): Promise<number>公开方法;参数与返回类型以签名列为准。
sadd方法sadd(key: string, ...members: string[]): Promise<number>公开方法;参数与返回类型以签名列为准。
set方法set(key: string, value: string, mode: "PX", durationMilliseconds: number): Promise<unknown>公开方法;参数与返回类型以签名列为准。
smembers方法smembers(key: string): Promise<string[]>公开方法;参数与返回类型以签名列为准。
srem方法srem(key: string, ...members: string[]): Promise<number>公开方法;参数与返回类型以签名列为准。

RedisMemorySearchCacheOptions

Redis Memory Search Cache Options 接口,共包含 4 个公开字段或方法。

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

声明

text
export interface RedisMemorySearchCacheOptions {
    client: RedisLikeMemorySearchCacheClient;
    namespace?: string;
    maxEntryBytes?: number;
    now?: () => number;
}

契约成员

成员种类签名说明
client属性client: RedisLikeMemorySearchCacheClient公开属性;类型、只读和可选状态以签名列为准。
maxEntryBytes属性maxEntryBytes?: number公开属性;类型、只读和可选状态以签名列为准。
namespace属性namespace?: string公开属性;类型、只读和可选状态以签名列为准。
now方法now?(): number公开方法;参数与返回类型以签名列为准。

MemorySearchCacheCompositionOptions

Memory Search Cache Composition Options 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { MemorySearchCacheCompositionOptions } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-search-cache

声明

text
export type MemorySearchCacheCompositionOptions = {
    mode: 'disabled';
    provider: MemoryManagementProvider;
} | (CachedMemoryManagementProviderOptions & {
    mode: 'enabled';
});

MemorySearchCacheFailureMode

Memory Search Cache Failure Mode 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { MemorySearchCacheFailureMode } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-search-cache

声明

text
export type MemorySearchCacheFailureMode = 'bypass' | 'strict';

MemorySearchCacheMode

Memory Search Cache Mode 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { MemorySearchCacheMode } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-search-cache

声明

text
export type MemorySearchCacheMode = 'enabled' | 'disabled';

MemorySearchCacheRecord

Memory Search Cache Record 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { MemorySearchCacheRecord } from '@codesoul-co/hypha-memory';
  • 源码模块: managed-search-cache

声明

text
export type MemorySearchCacheRecord = z.infer<typeof memorySearchCacheRecordSchema>;