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"