MCPcopy
hub / github.com/cpaczek/skylight / load

Method load

server/src/tle.ts:40–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38 ) {}
39
40 async load(): Promise<void> {
41 try {
42 const raw = await readFile(this.cachePath, "utf8");
43 const parsed = JSON.parse(raw) as { at: number; tles: Tle[] };
44 this.tles = parsed.tles ?? [];
45 this.fetchedAt = parsed.at ?? 0;
46 } catch {
47 /* first run */
48 }
49 // Refresh on startup (non-blocking) and then on a daily timer.
50 void this.refresh();
51 setInterval(() => void this.refresh(), 6 * 3600_000).unref?.();
52 }
53
54 async get(): Promise<Tle[]> {
55 if (Date.now() - this.fetchedAt > this.ttlMs) await this.refresh();

Callers 1

mainFunction · 0.95

Calls 1

refreshMethod · 0.95

Tested by

no test coverage detected