* Gc and update location. * @private * @param {Items} items items * @param {Items} usedItems used items * @param {number} newLoc new location
(items, usedItems, newLoc)
| 270 | * @param {number} newLoc new location |
| 271 | */ |
| 272 | _gcAndUpdateLocation(items, usedItems, newLoc) { |
| 273 | let count = 0; |
| 274 | /** @type {undefined | string} */ |
| 275 | let lastGC; |
| 276 | const now = Date.now(); |
| 277 | for (const identifier of items) { |
| 278 | const info = /** @type {PackItemInfo} */ (this.itemInfo.get(identifier)); |
| 279 | if (now - info.lastAccess > this.maxAge) { |
| 280 | this.itemInfo.delete(identifier); |
| 281 | items.delete(identifier); |
| 282 | usedItems.delete(identifier); |
| 283 | count++; |
| 284 | lastGC = identifier; |
| 285 | } else { |
| 286 | info.location = newLoc; |
| 287 | } |
| 288 | } |
| 289 | if (count > 0) { |
| 290 | this.logger.log( |
| 291 | "Garbage Collected %d old items at pack %d (%d items remaining) e. g. %s", |
| 292 | count, |
| 293 | newLoc, |
| 294 | items.size, |
| 295 | lastGC |
| 296 | ); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | _persistFreshContent() { |
| 301 | /** @typedef {{ items: Items, map: Content, loc: number }} PackItem */ |
no test coverage detected