()
| 276 | } |
| 277 | |
| 278 | function checkAndEvictCache(): void { |
| 279 | if (wcvCache.size <= MaxCacheSize) { |
| 280 | return; |
| 281 | } |
| 282 | const sorted = Array.from(wcvCache.values()).sort((a, b) => { |
| 283 | // Prioritize entries which are active |
| 284 | if (a.isActiveTab && !b.isActiveTab) { |
| 285 | return -1; |
| 286 | } |
| 287 | // Otherwise, sort by lastUsedTs |
| 288 | return a.lastUsedTs - b.lastUsedTs; |
| 289 | }); |
| 290 | for (let i = 0; i < sorted.length - MaxCacheSize; i++) { |
| 291 | tryEvictEntry(sorted[i].waveTabId); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | export function clearTabCache() { |
| 296 | const wcVals = Array.from(wcvCache.values()); |
no test coverage detected