From 2d49f1bad8c33ea2ed033c3ca2d55beed399e10b Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Sun, 5 Jul 2026 17:55:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(cache):=20=E6=96=B0=E5=A2=9E=20index.ts=20?= =?UTF-8?q?=E5=85=AC=E5=85=B1=20API=20=E8=81=9A=E5=90=88=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/lib/cache/index.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/shared/lib/cache/index.ts diff --git a/src/shared/lib/cache/index.ts b/src/shared/lib/cache/index.ts new file mode 100644 index 0000000..2ef1603 --- /dev/null +++ b/src/shared/lib/cache/index.ts @@ -0,0 +1,27 @@ +/** + * 缓存基础设施公共 API。 + * + * 服务端调用方使用: + * - data-access:`cacheFn(fn, { tags, ttl, keyParts })` 包装查询函数 + * - actions:`invalidateFor(actionId, params)` 编排写操作后失效 + * + * 客户端调用方使用: + * - `CLIENT_INVALIDATION_MAP` 查询 queryKey 失效列表(自动由 useActionMutation 调用) + */ + +export { cacheFn } from "./cache-fn" +export { invalidateFor } from "./invalidate" +export { + INVALIDATION_MAP, + fillTemplate, +} from "./invalidation-map" +export type { + CacheFnOptions, + CacheStore, + InvalidationRule, +} from "./types" +export type { InvalidationActionId } from "./invalidation-map" + +// 客户端可见的子集(无 server-only 依赖) +export { CLIENT_INVALIDATION_MAP } from "./client-invalidation-map" +export type { ClientInvalidationActionId } from "./client-invalidation-map"