MCPcopy
hub / github.com/webpack/webpack / set

Method set

lib/cache/PackFileCacheStrategy.js:209–237  ·  view source on GitHub ↗

* Updates value using the provided identifier. * @param {string} identifier unique name for the resource * @param {string | null} etag etag of the resource * @param {Data} data cached content * @returns {void}

(identifier, etag, data)

Source from the content-addressed store, hash-verified

207 * @returns {void}
208 */
209 set(identifier, etag, data) {
210 if (!this.invalid) {
211 this.invalid = true;
212 this.logger.log(`Pack got invalid because of write to: ${identifier}`);
213 }
214 const info = this.itemInfo.get(identifier);
215 if (info === undefined) {
216 const newInfo = new PackItemInfo(identifier, etag, data);
217 this.itemInfo.set(identifier, newInfo);
218 this._addRequest(identifier);
219 this.freshContent.set(identifier, newInfo);
220 } else {
221 const loc = info.location;
222 if (loc >= 0) {
223 this._addRequest(identifier);
224 this.freshContent.set(identifier, info);
225 const content = /** @type {PackContent} */ (this.content[loc]);
226 content.delete(identifier);
227 if (content.items.size === 0) {
228 this.content[loc] = undefined;
229 this.logger.debug("Pack %d got empty and is removed", loc);
230 }
231 }
232 info.freshValue = data;
233 info.lastAccess = Date.now();
234 info.etag = etag;
235 info.location = -1;
236 }
237 }
238
239 getContentStats() {
240 let count = 0;

Callers 15

applyMethod · 0.45
getterFunction · 0.45
_persistFreshContentMethod · 0.45
_optimizeSmallContentMethod · 0.45
_gcOldestContentMethod · 0.45
deserializeMethod · 0.45
deserializeMethod · 0.45
writeLazyMethod · 0.45
storeMethod · 0.45
afterAllStoredMethod · 0.45
mergeEtagsFunction · 0.45

Calls 5

_addRequestMethod · 0.95
logMethod · 0.80
debugMethod · 0.80
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected