@isdk/proxy 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.cn.md +249 -9
  2. package/README.md +249 -7
  3. package/dist/index.d.mts +374 -41
  4. package/dist/index.d.ts +374 -41
  5. package/dist/index.js +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/docs/README.md +249 -7
  8. package/docs/classes/OfflineCacheMissError.md +426 -0
  9. package/docs/classes/SmartCache.md +81 -13
  10. package/docs/functions/createCachedFetch.md +1 -1
  11. package/docs/functions/createFetchWithCache.md +1 -1
  12. package/docs/functions/extractData.md +34 -5
  13. package/docs/functions/fetchWithCache.md +18 -9
  14. package/docs/functions/generateCacheKey.md +34 -4
  15. package/docs/functions/getSiteConfig.md +39 -0
  16. package/docs/functions/isAllowed.md +35 -8
  17. package/docs/functions/isCacheable.md +27 -0
  18. package/docs/functions/isGlob.md +23 -0
  19. package/docs/functions/isMatch.md +44 -0
  20. package/docs/functions/prefetch.md +33 -0
  21. package/docs/globals.md +15 -0
  22. package/docs/interfaces/BodyFilterConfig.md +77 -0
  23. package/docs/interfaces/CacheEntry.md +9 -9
  24. package/docs/interfaces/CacheMetadata.md +8 -8
  25. package/docs/interfaces/CacheRule.md +80 -0
  26. package/docs/interfaces/FetchWithCacheContext.md +44 -16
  27. package/docs/interfaces/FetchWithCacheOptions.md +40 -12
  28. package/docs/interfaces/KeyFilterConfig.md +11 -7
  29. package/docs/interfaces/PrefetchOptions.md +107 -0
  30. package/docs/interfaces/PrefetchRequest.md +31 -0
  31. package/docs/interfaces/PrefetchResult.md +47 -0
  32. package/docs/interfaces/ProxyConfig.md +4 -4
  33. package/docs/interfaces/SiteCacheConfig.md +56 -11
  34. package/docs/interfaces/SmartCacheOptions.md +32 -6
  35. package/docs/variables/OfflineCacheMissErrorCode.md +18 -0
  36. package/package.json +5 -3
@@ -0,0 +1,426 @@
1
+ [**@isdk/proxy**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/proxy](../globals.md) / OfflineCacheMissError
6
+
7
+ # Class: OfflineCacheMissError
8
+
9
+ Defined in: [packages/proxy/src/errors.ts:24](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/errors.ts#L24)
10
+
11
+ Offline 缓存未命中错误
12
+
13
+ ## Example
14
+
15
+ ```ts
16
+ throw new OfflineCacheMissError('http://example.com/data')
17
+ ```
18
+
19
+ ## Extends
20
+
21
+ - `CommonError`
22
+
23
+ ## Constructors
24
+
25
+ ### Constructor
26
+
27
+ > **new OfflineCacheMissError**(`url`, `name?`): `OfflineCacheMissError`
28
+
29
+ Defined in: [packages/proxy/src/errors.ts:26](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/errors.ts#L26)
30
+
31
+ #### Parameters
32
+
33
+ ##### url
34
+
35
+ `string` | `number`
36
+
37
+ ##### name?
38
+
39
+ `string` | `Record`\<`string`, `any`\>
40
+
41
+ #### Returns
42
+
43
+ `OfflineCacheMissError`
44
+
45
+ #### Overrides
46
+
47
+ `CommonError.constructor`
48
+
49
+ ## Properties
50
+
51
+ ### caller
52
+
53
+ > **caller**: `string`
54
+
55
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:141
56
+
57
+ #### Inherited from
58
+
59
+ `CommonError.caller`
60
+
61
+ ***
62
+
63
+ ### cause?
64
+
65
+ > `optional` **cause**: `unknown`
66
+
67
+ Defined in: node\_modules/.pnpm/typescript@5.7.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
68
+
69
+ #### Inherited from
70
+
71
+ `CommonError.cause`
72
+
73
+ ***
74
+
75
+ ### code
76
+
77
+ > **code**: `ErrorCodeType`
78
+
79
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:142
80
+
81
+ the error code
82
+
83
+ #### Inherited from
84
+
85
+ `CommonError.code`
86
+
87
+ ***
88
+
89
+ ### data?
90
+
91
+ > `optional` **data**: `any`
92
+
93
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:143
94
+
95
+ #### Inherited from
96
+
97
+ `CommonError.data`
98
+
99
+ ***
100
+
101
+ ### message
102
+
103
+ > **message**: `string`
104
+
105
+ Defined in: node\_modules/.pnpm/typescript@5.7.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
106
+
107
+ #### Inherited from
108
+
109
+ `CommonError.message`
110
+
111
+ ***
112
+
113
+ ### name
114
+
115
+ > **name**: `string`
116
+
117
+ Defined in: node\_modules/.pnpm/typescript@5.7.3/node\_modules/typescript/lib/lib.es5.d.ts:1076
118
+
119
+ #### Inherited from
120
+
121
+ `CommonError.name`
122
+
123
+ ***
124
+
125
+ ### stack?
126
+
127
+ > `optional` **stack**: `string`
128
+
129
+ Defined in: node\_modules/.pnpm/typescript@5.7.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
130
+
131
+ #### Inherited from
132
+
133
+ `CommonError.stack`
134
+
135
+ ***
136
+
137
+ ### code
138
+
139
+ > `static` **code**: `ErrorCode` = `OfflineCacheMissErrorCode`
140
+
141
+ Defined in: [packages/proxy/src/errors.ts:25](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/errors.ts#L25)
142
+
143
+ The error code associated with the error.
144
+
145
+ #### Overrides
146
+
147
+ `CommonError.code`
148
+
149
+ ***
150
+
151
+ ### stackTraceLimit
152
+
153
+ > `static` **stackTraceLimit**: `number`
154
+
155
+ Defined in: node\_modules/.pnpm/@types+node@20.19.26/node\_modules/@types/node/globals.d.ts:68
156
+
157
+ The `Error.stackTraceLimit` property specifies the number of stack frames
158
+ collected by a stack trace (whether generated by `new Error().stack` or
159
+ `Error.captureStackTrace(obj)`).
160
+
161
+ The default value is `10` but may be set to any valid JavaScript number. Changes
162
+ will affect any stack trace captured _after_ the value has been changed.
163
+
164
+ If set to a non-number value, or set to a negative number, stack traces will
165
+ not capture any frames.
166
+
167
+ #### Inherited from
168
+
169
+ `CommonError.stackTraceLimit`
170
+
171
+ ## Methods
172
+
173
+ ### fromJSON()
174
+
175
+ > **fromJSON**(`json`): `BaseError`
176
+
177
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:183
178
+
179
+ #### Parameters
180
+
181
+ ##### json
182
+
183
+ `any`
184
+
185
+ #### Returns
186
+
187
+ `BaseError`
188
+
189
+ #### Inherited from
190
+
191
+ `CommonError.fromJSON`
192
+
193
+ ***
194
+
195
+ ### toJSON()
196
+
197
+ > **toJSON**(): `any`
198
+
199
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:165
200
+
201
+ Returns a JSON representation of the error.
202
+
203
+ #### Returns
204
+
205
+ `any`
206
+
207
+ A JSON representation of the error.
208
+
209
+ #### Inherited from
210
+
211
+ `CommonError.toJSON`
212
+
213
+ ***
214
+
215
+ ### captureStackTrace()
216
+
217
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
218
+
219
+ Defined in: node\_modules/.pnpm/@types+node@20.19.26/node\_modules/@types/node/globals.d.ts:52
220
+
221
+ Creates a `.stack` property on `targetObject`, which when accessed returns
222
+ a string representing the location in the code at which
223
+ `Error.captureStackTrace()` was called.
224
+
225
+ ```js
226
+ const myObject = {};
227
+ Error.captureStackTrace(myObject);
228
+ myObject.stack; // Similar to `new Error().stack`
229
+ ```
230
+
231
+ The first line of the trace will be prefixed with
232
+ `${myObject.name}: ${myObject.message}`.
233
+
234
+ The optional `constructorOpt` argument accepts a function. If given, all frames
235
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
236
+ generated stack trace.
237
+
238
+ The `constructorOpt` argument is useful for hiding implementation
239
+ details of error generation from the user. For instance:
240
+
241
+ ```js
242
+ function a() {
243
+ b();
244
+ }
245
+
246
+ function b() {
247
+ c();
248
+ }
249
+
250
+ function c() {
251
+ // Create an error without stack trace to avoid calculating the stack trace twice.
252
+ const { stackTraceLimit } = Error;
253
+ Error.stackTraceLimit = 0;
254
+ const error = new Error();
255
+ Error.stackTraceLimit = stackTraceLimit;
256
+
257
+ // Capture the stack trace above function b
258
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
259
+ throw error;
260
+ }
261
+
262
+ a();
263
+ ```
264
+
265
+ #### Parameters
266
+
267
+ ##### targetObject
268
+
269
+ `object`
270
+
271
+ ##### constructorOpt?
272
+
273
+ `Function`
274
+
275
+ #### Returns
276
+
277
+ `void`
278
+
279
+ #### Inherited from
280
+
281
+ `CommonError.captureStackTrace`
282
+
283
+ ***
284
+
285
+ ### create()
286
+
287
+ > `static` **create**(`__namedParameters`): `CommonError`
288
+
289
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:186
290
+
291
+ #### Parameters
292
+
293
+ ##### \_\_namedParameters
294
+
295
+ ###### code?
296
+
297
+ `string` \| `number`
298
+
299
+ ###### data?
300
+
301
+ `any`
302
+
303
+ ###### error
304
+
305
+ `string`
306
+
307
+ ###### name?
308
+
309
+ `string`
310
+
311
+ #### Returns
312
+
313
+ `CommonError`
314
+
315
+ #### Inherited from
316
+
317
+ `CommonError.create`
318
+
319
+ ***
320
+
321
+ ### createErrorClass()
322
+
323
+ > `static` **createErrorClass**(`aType`, `aErrorCode?`, `ParentErrorClass?`): *typeof* `BaseError`
324
+
325
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:145
326
+
327
+ Create an Error Class
328
+
329
+ #### Parameters
330
+
331
+ ##### aType
332
+
333
+ `string`
334
+
335
+ the error type(class) name
336
+
337
+ ##### aErrorCode?
338
+
339
+ `string` | `number` | *typeof* `AbstractError`
340
+
341
+ ##### ParentErrorClass?
342
+
343
+ *typeof* `BaseError`
344
+
345
+ the parent error class. defaults to AbstractError
346
+
347
+ #### Returns
348
+
349
+ *typeof* `BaseError`
350
+
351
+ the new Error Class
352
+
353
+ #### Inherited from
354
+
355
+ `CommonError.createErrorClass`
356
+
357
+ ***
358
+
359
+ ### fromJSON()
360
+
361
+ > `static` **fromJSON**(`json`): `BaseError`
362
+
363
+ Defined in: node\_modules/.pnpm/@isdk+common-error@0.2.2/node\_modules/@isdk/common-error/dist/index.d.ts:182
364
+
365
+ Creates a new error instance from a JSON representation.
366
+ This method is useful for deserializing an error that was serialized with `toJSON`.
367
+
368
+ #### Parameters
369
+
370
+ ##### json
371
+
372
+ `any`
373
+
374
+ A JSON object representing the error.
375
+
376
+ #### Returns
377
+
378
+ `BaseError`
379
+
380
+ A new instance of the error class (or a subclass).
381
+
382
+ #### Example
383
+
384
+ ```ts
385
+ const originalError = new NotFoundError('thing');
386
+ const json = originalError.toJSON();
387
+
388
+ // Deserialize
389
+ const newError = NotFoundError.fromJSON(json);
390
+ console.log(newError instanceof NotFoundError); // true
391
+ console.log(newError.message); // 'Could not find thing.'
392
+ ```
393
+
394
+ #### Inherited from
395
+
396
+ `CommonError.fromJSON`
397
+
398
+ ***
399
+
400
+ ### prepareStackTrace()
401
+
402
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
403
+
404
+ Defined in: node\_modules/.pnpm/@types+node@20.19.26/node\_modules/@types/node/globals.d.ts:56
405
+
406
+ #### Parameters
407
+
408
+ ##### err
409
+
410
+ `Error`
411
+
412
+ ##### stackTraces
413
+
414
+ `CallSite`[]
415
+
416
+ #### Returns
417
+
418
+ `any`
419
+
420
+ #### See
421
+
422
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
423
+
424
+ #### Inherited from
425
+
426
+ `CommonError.prepareStackTrace`
@@ -6,9 +6,19 @@
6
6
 
7
7
  # Class: SmartCache
8
8
 
9
- Defined in: [core/SmartCache.ts:22](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L22)
9
+ Defined in: [packages/proxy/src/core/SmartCache.ts:39](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L39)
10
10
 
11
- 智能混合缓存类 (Hybrid Cache)
11
+ 智能混合缓存类 (Hybrid Multi-tier Cache)
12
+
13
+ 该类实现了 L1 (内存) 和 L2 (磁盘) 的双层混合存储架构,旨在提供高性能且大容量的缓存能力。
14
+
15
+ ### 核心特性:
16
+ - **双层架构**: L1 使用 LRU 内存缓存(基于 `secondary-cache` 的 LRUCache),L2 使用持久化磁盘缓存(基于 `cacache`)。
17
+ - **大小感知存储**: 自动识别响应体大小。小于阈值的文件同时存于内存和磁盘;超过阈值的文件仅存于磁盘,但其元数据仍保留在内存中。
18
+ - **元数据驻留 (Meta-Residency)**: 无论 Body 多大,Headers、Status、Policy 等信息始终优先从内存读取,确保缓存判定性能。
19
+ - **流式支持**: 支持通过 `setStream` 和 `getStream` 直接操作大数据流,防止 OOM。
20
+ - **一致性保障**: 在并发写入时自动清理内存,确保后续读取不会拿到被污染的旧数据。
21
+ - **内存限制**: 通过 `maxTotalMemorySize` 控制 L1 缓存的总内存占用。
12
22
 
13
23
  ## Constructors
14
24
 
@@ -16,7 +26,7 @@ Defined in: [core/SmartCache.ts:22](https://github.com/isdk/proxy.js/blob/bed37f
16
26
 
17
27
  > **new SmartCache**(`options`): `SmartCache`
18
28
 
19
- Defined in: [core/SmartCache.ts:27](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L27)
29
+ Defined in: [packages/proxy/src/core/SmartCache.ts:44](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L44)
20
30
 
21
31
  #### Parameters
22
32
 
@@ -32,9 +42,19 @@ Defined in: [core/SmartCache.ts:27](https://github.com/isdk/proxy.js/blob/bed37f
32
42
 
33
43
  ### clear()
34
44
 
35
- > **clear**(): `Promise`\<`void`\>
45
+ > **clear**(`clearPersistent?`): `Promise`\<`void`\>
46
+
47
+ Defined in: [packages/proxy/src/core/SmartCache.ts:202](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L202)
48
+
49
+ Clears the cache. By default, both the in-memory cache and the persistent disk cache are cleared.
50
+
51
+ #### Parameters
52
+
53
+ ##### clearPersistent?
54
+
55
+ `boolean` = `true`
36
56
 
37
- Defined in: [core/SmartCache.ts:122](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L122)
57
+ Whether to clear the persistent (disk) cache. Defaults to `true` for backward compatibility.
38
58
 
39
59
  #### Returns
40
60
 
@@ -44,9 +64,11 @@ Defined in: [core/SmartCache.ts:122](https://github.com/isdk/proxy.js/blob/bed37
44
64
 
45
65
  ### delete()
46
66
 
47
- > **delete**(`key`): `Promise`\<`void`\>
67
+ > **delete**(`key`, `clearPersistent?`): `Promise`\<`void`\>
48
68
 
49
- Defined in: [core/SmartCache.ts:117](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L117)
69
+ Defined in: [packages/proxy/src/core/SmartCache.ts:193](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L193)
70
+
71
+ Deletes the cache entry for the specified key.
50
72
 
51
73
  #### Parameters
52
74
 
@@ -54,6 +76,14 @@ Defined in: [core/SmartCache.ts:117](https://github.com/isdk/proxy.js/blob/bed37
54
76
 
55
77
  `string`
56
78
 
79
+ The cache key to delete
80
+
81
+ ##### clearPersistent?
82
+
83
+ `boolean` = `true`
84
+
85
+ Whether to also delete the entry from persistent (disk) storage. Defaults to `true`.
86
+
57
87
  #### Returns
58
88
 
59
89
  `Promise`\<`void`\>
@@ -64,10 +94,15 @@ Defined in: [core/SmartCache.ts:117](https://github.com/isdk/proxy.js/blob/bed37
64
94
 
65
95
  > **get**(`key`): `Promise`\<[`CacheEntry`](../interfaces/CacheEntry.md) \| `null`\>
66
96
 
67
- Defined in: [core/SmartCache.ts:41](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L41)
97
+ Defined in: [packages/proxy/src/core/SmartCache.ts:79](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L79)
68
98
 
69
99
  获取缓存条目
70
- 如果是小文件,返回带 Buffer 的 Entry;如果是大文件,返回带 ReadStream 的 Entry。
100
+
101
+ 逻辑:
102
+ 1. 首先尝试从 L1 内存获取。
103
+ 2. 如果内存中有 Body,直接返回(Buffer 类型)。
104
+ 3. 如果内存中只有 Meta(大文件),则从 L2 磁盘创建并返回 ReadStream。
105
+ 4. 如果内存完全未命中,从磁盘 L2 检索,并根据大小决定是否回填 L1。
71
106
 
72
107
  #### Parameters
73
108
 
@@ -75,17 +110,25 @@ Defined in: [core/SmartCache.ts:41](https://github.com/isdk/proxy.js/blob/bed37f
75
110
 
76
111
  `string`
77
112
 
113
+ 缓存指纹键
114
+
78
115
  #### Returns
79
116
 
80
117
  `Promise`\<[`CacheEntry`](../interfaces/CacheEntry.md) \| `null`\>
81
118
 
119
+ 完整的缓存条目(带 Buffer 或 Stream 的 Body),未命中返回 null
120
+
82
121
  ***
83
122
 
84
123
  ### getStream()
85
124
 
86
125
  > **getStream**(`key`): `ReadableStream`
87
126
 
88
- Defined in: [core/SmartCache.ts:107](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L107)
127
+ Defined in: [packages/proxy/src/core/SmartCache.ts:159](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L159)
128
+
129
+ 获取磁盘读取流
130
+
131
+ 允许直接从 L2 磁盘层以流的形式读取数据,适用于大文件代理。
89
132
 
90
133
  #### Parameters
91
134
 
@@ -93,19 +136,25 @@ Defined in: [core/SmartCache.ts:107](https://github.com/isdk/proxy.js/blob/bed37
93
136
 
94
137
  `string`
95
138
 
139
+ 缓存指纹键
140
+
96
141
  #### Returns
97
142
 
98
143
  `ReadableStream`
99
144
 
145
+ Node.js 可读流
146
+
100
147
  ***
101
148
 
102
149
  ### set()
103
150
 
104
151
  > **set**(`key`, `body`, `metadata`): `Promise`\<`void`\>
105
152
 
106
- Defined in: [core/SmartCache.ts:85](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L85)
153
+ Defined in: [packages/proxy/src/core/SmartCache.ts:129](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L129)
154
+
155
+ 写入缓存条目 (原子写入)
107
156
 
108
- 写入缓存
157
+ 适用于已知长度的小型数据块。该操作会同时写入磁盘并回填内存(如果大小未超标)。
109
158
 
110
159
  #### Parameters
111
160
 
@@ -113,14 +162,20 @@ Defined in: [core/SmartCache.ts:85](https://github.com/isdk/proxy.js/blob/bed37f
113
162
 
114
163
  `string`
115
164
 
165
+ 缓存指纹键
166
+
116
167
  ##### body
117
168
 
118
169
  `Buffer`
119
170
 
171
+ 响应体数据 Buffer
172
+
120
173
  ##### metadata
121
174
 
122
175
  `Omit`\<[`CacheMetadata`](../interfaces/CacheMetadata.md), `"size"`\>
123
176
 
177
+ 响应元数据(不含 size,由本方法自动计算)
178
+
124
179
  #### Returns
125
180
 
126
181
  `Promise`\<`void`\>
@@ -131,7 +186,14 @@ Defined in: [core/SmartCache.ts:85](https://github.com/isdk/proxy.js/blob/bed37f
131
186
 
132
187
  > **setStream**(`key`, `metadata`): `WritableStream`
133
188
 
134
- Defined in: [core/SmartCache.ts:111](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/SmartCache.ts#L111)
189
+ Defined in: [packages/proxy/src/core/SmartCache.ts:175](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/SmartCache.ts#L175)
190
+
191
+ 获取磁盘写入流 (流式缓存)
192
+
193
+ 该方法用于支持真正的流式代理。它会执行以下一致性操作:
194
+ 1. 立即清除 L1 内存中的对应键,防止读到旧数据。
195
+ 2. 返回一个可写流,数据将直接流入磁盘。
196
+ 3. **一致性修复**: 在流写入完成(finish)时再次清理内存,防止写入期间的并发读取将旧数据再次回填进内存。
135
197
 
136
198
  #### Parameters
137
199
 
@@ -139,10 +201,16 @@ Defined in: [core/SmartCache.ts:111](https://github.com/isdk/proxy.js/blob/bed37
139
201
 
140
202
  `string`
141
203
 
204
+ 缓存指纹键
205
+
142
206
  ##### metadata
143
207
 
144
208
  `Omit`\<[`CacheMetadata`](../interfaces/CacheMetadata.md), `"size"`\>
145
209
 
210
+ 响应元数据
211
+
146
212
  #### Returns
147
213
 
148
214
  `WritableStream`
215
+
216
+ Node.js 可写流
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **createCachedFetch**(`defaultOptions`): (`request`, `fetcher`, `overrideOptions?`) => `Promise`\<`Response`\>
10
10
 
11
- Defined in: [core/createCachedFetch.ts:17](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/createCachedFetch.ts#L17)
11
+ Defined in: [packages/proxy/src/core/createCachedFetch.ts:17](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/createCachedFetch.ts#L17)
12
12
 
13
13
  缓存请求工厂函数 (针对终端用户的顶层高阶 API)
14
14
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  > **createFetchWithCache**(`activeCacheWrites?`): (`request`, `fetcher`, `options`) => `Promise`\<`Response`\>
10
10
 
11
- Defined in: [core/createFetchWithCache.ts:16](https://github.com/isdk/proxy.js/blob/bed37fa43507dcbe5cdfa453876163571399d761/src/core/createFetchWithCache.ts#L16)
11
+ Defined in: [packages/proxy/src/core/createFetchWithCache.ts:16](https://github.com/isdk/proxy.js/blob/a1563efa4c3081261eb3af8a6404f1b704b33bf1/src/core/createFetchWithCache.ts#L16)
12
12
 
13
13
  单一职责高阶函数:专门用于封装和隔离 activeCacheWrites 并发追踪器。
14
14