Commit dc846b7
committed
improvement(memory): replace manual TTL Maps with lru-cache for toolSchemaCache and effectiveEnvCache
Replaces the homegrown Map + setInterval sweep pattern with LRUCache from
the lru-cache npm package, which is the standard Node.js solution for
bounded in-process caching with TTL.
Changes per cache:
- Removes manual ToolSchemaCacheEntry / EffectiveEnvCacheEntry types
- Removes setInterval sweep timers (and the .unref() boilerplate)
- Removes the two-phase promise->value entry update inside the IIFE
- Stores Promise<T> directly — in-flight and resolved states share one type
- max: 200 (toolSchemaCache) / max: 500 (effectiveEnvCache) as hard ceilings
- TTL behaviour and concurrent-request deduplication are preserved exactly
- cache-registry .size reporting works unchanged via lru-cache's .size prop1 parent 6766bd2 commit dc846b7
4 files changed
Lines changed: 24 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
31 | 22 | | |
32 | 23 | | |
33 | 24 | | |
| |||
84 | 75 | | |
85 | 76 | | |
86 | 77 | | |
87 | | - | |
| 78 | + | |
88 | 79 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 80 | + | |
| 81 | + | |
94 | 82 | | |
95 | 83 | | |
96 | 84 | | |
| |||
197 | 185 | | |
198 | 186 | | |
199 | 187 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | 188 | | |
206 | 189 | | |
207 | 190 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 191 | + | |
212 | 192 | | |
213 | 193 | | |
214 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
33 | 24 | | |
34 | 25 | | |
35 | 26 | | |
| |||
335 | 326 | | |
336 | 327 | | |
337 | 328 | | |
338 | | - | |
339 | | - | |
340 | 329 | | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
347 | 333 | | |
348 | 334 | | |
349 | 335 | | |
350 | 336 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
359 | 341 | | |
360 | 342 | | |
361 | 343 | | |
362 | 344 | | |
363 | 345 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 346 | + | |
369 | 347 | | |
370 | 348 | | |
371 | 349 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments