(key: string, at: number)
| 80 | const touchCacheKey = (tenant: string, externalId: string) => `${tenant} ${externalId}`; |
| 81 | |
| 82 | const rememberTouch = (key: string, at: number): void => { |
| 83 | // Re-insert so the key moves to the end of the Map's insertion order, making |
| 84 | // the oldest-touched entry the natural eviction target. |
| 85 | lastTouchedAt.delete(key); |
| 86 | lastTouchedAt.set(key, at); |
| 87 | if (lastTouchedAt.size > MAX_TRACKED_SUBJECTS) { |
| 88 | const oldest = lastTouchedAt.keys().next(); |
| 89 | if (!oldest.done) lastTouchedAt.delete(oldest.value); |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | /** Test seam: drop the process-local sighting memory. */ |
| 94 | export const resetSubjectTouchCache = (): void => { |
no test coverage detected