* 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)
| 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; |
no test coverage detected