MCPcopy
hub / github.com/webpack/webpack / _gcAndUpdateLocation

Method _gcAndUpdateLocation

lib/cache/PackFileCacheStrategy.js:272–298  ·  view source on GitHub ↗

* Gc and update location. * @private * @param {Items} items items * @param {Items} usedItems used items * @param {number} newLoc new location

(items, usedItems, newLoc)

Source from the content-addressed store, hash-verified

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 */

Callers 3

_optimizeSmallContentMethod · 0.95
_gcOldestContentMethod · 0.95

Calls 3

logMethod · 0.80
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected