storage.ts ×8

Frontier kind: Code frontier

unlabeled · c_b64caeb05eda

450 tests · 12507 LOC · 50 files · introduces 0 tests · 44 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges44 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1798 ranges12507 lines · 50 files · Browse complete extent
All tests (intent)
450 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 44 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/parts/storage/common/storage.ts 44 introduced LOC · 8 ranges

Open complete file

263
264 async set(key: string, value: string | boolean | number | null | undefined | object, external = false): Promise<void> {
265 > if (this.state === StorageState.Closed) { storage.ts
266 return; // Return early if we are already closed
267 }
268 > storage.ts
269 > // We remove the key for undefined/null values
270 > if (isUndefinedOrNull(value)) {
271 return this.delete(key, external);
272 }
273 > storage.ts
274 > // Otherwise, convert to String and store
275 > const valueStr = isObject(value) || Array.isArray(value) ? stringify(value) : String(value);
276 >
277 > // Return early if value already set
278 > const currentValue = this.cache.get(key);
279 > if (currentValue === valueStr) {
280 return;
281 }
282 > storage.ts
283 > // Update in cache and pending
284 > this.cache.set(key, valueStr);
285 > this.pendingInserts.set(key, valueStr);
286 > this.pendingDeletes.delete(key);
287 >
288 > // Event
289 > this._onDidChangeStorage.fire({ key, external });
290 >
291 > // Accumulate work by scheduling after timeout
292 > return this.doFlush();
293 > }
294
295 async delete(key: string, external = false): Promise<void> {
362
363 private async flushPending(): Promise<void> {
364 > if (!this.hasPending) { storage.ts
365 return; // return early if nothing to do
366 }
367 > storage.ts
368 > // Get pending data
369 > const updateRequest: IUpdateRequest = { insert: this.pendingInserts, delete: this.pendingDeletes };
370 >
371 > // Reset pending data for next run
372 > this.pendingDeletes = new Set<string>();
373 > this.pendingInserts = new Map<string, string>();
374 >
375 > // Update in storage and release any
376 > // waiters we have once done
377 > return this.database.updateItems(updateRequest).finally(() => {
378 > if (!this.hasPending) {
379 > while (this.whenFlushedCallbacks.length) {
380 this.whenFlushedCallbacks.pop()?.();
381 }
382 > } storage.ts
383 > });
384 > }
385
386 async flush(delay?: number): Promise<void> {
427
428 async updateItems(request: IUpdateRequest): Promise<void> {
429 > request.insert?.forEach((value, key) => this.items.set(key, value)); storage.ts
430 >
431 > request.delete?.forEach(key => this.items.delete(key));
432 > }
433
434 async optimize(): Promise<void> { }