MCPcopy Create free account
hub / github.com/coder/coder / garbageCollectStoredLatencies

Function garbageCollectStoredLatencies

site/src/contexts/useProxyLatency.ts:287–301  ·  view source on GitHub ↗
(
	regions: readonly Region[],
	maxStored: number,
)

Source from the content-addressed store, hash-verified

285// garbageCollectStoredLatencies will remove any latencies that are older then 1 week or latencies of proxies
286// that no longer exist. This is intended to keep the size of local storage down.
287const garbageCollectStoredLatencies = (
288 regions: readonly Region[],
289 maxStored: number,
290): void => {
291 const latencies = loadStoredLatencies();
292 const now = Date.now();
293 const cleaned = cleanupLatencies(
294 latencies,
295 regions,
296 new Date(now),
297 maxStored,
298 );
299
300 localStorage.setItem("workspace-proxy-latencies", JSON.stringify(cleaned));
301};
302
303const cleanupLatencies = (
304 stored: Record<string, ProxyLatencyReport[]>,

Callers 1

useProxyLatencyFunction · 0.85

Calls 3

loadStoredLatenciesFunction · 0.85
cleanupLatenciesFunction · 0.85
nowMethod · 0.45

Tested by

no test coverage detected