MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / saveToCache

Function saveToCache

website/src/pages/Explore.tsx:424–450  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

422 if (!graphData) return;
423
424 const saveToCache = async () => {
425 let cacheRef = repoRef;
426 const metaRepo = graphData.metadata?.repo || "";
427
428 if (!cacheRef && metaRepo.includes("/")) {
429 const parts = metaRepo.split("/").filter(Boolean);
430 const repoName = parts[parts.length - 1];
431 const ownerPath = parts.slice(0, -1).join("/");
432 const provider = graphData.metadata?.provider === "gitlab" ? "gitlab" : "github";
433 cacheRef = {
434 provider,
435 owner: ownerPath,
436 repo: repoName,
437 fullPath: metaRepo,
438 host: provider === "gitlab" ? "gitlab.com" : "github.com",
439 };
440 }
441
442 if (!cacheRef) return;
443
444 try {
445 await cacheGraph(cacheRef, graphData);
446 console.log(`[Cache] Automatically cached active graph for ${cacheRef.fullPath} in IndexedDB.`);
447 } catch (cacheErr) {
448 console.warn("[Cache] Failed to auto-save graph to IndexedDB:", cacheErr);
449 }
450 };
451
452 saveToCache();
453 }, [graphData, repoRef]);

Callers 1

ExploreFunction · 0.85

Calls 2

cacheGraphFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected