MCPcopy Create free account
hub / github.com/github/gh-aw / SetBuiltinFrontmatterCache

Function SetBuiltinFrontmatterCache

pkg/parser/virtual_fs.go:89–103  ·  view source on GitHub ↗

SetBuiltinFrontmatterCache stores a FrontmatterResult for a builtin virtual file. The stored result becomes shared and read-only — callers MUST NOT mutate it (or its contained maps/slices) after this call. Uses LoadOrStore so concurrent races are safe; the winning value is returned.

(path string, result *FrontmatterResult)

Source from the content-addressed store, hash-verified

87// (or its contained maps/slices) after this call.
88// Uses LoadOrStore so concurrent races are safe; the winning value is returned.
89func SetBuiltinFrontmatterCache(path string, result *FrontmatterResult) *FrontmatterResult {
90 actual, loaded := builtinFrontmatterCache.LoadOrStore(path, result)
91 if loaded {
92 virtualFsLog.Printf("Frontmatter cache already populated (race): path=%s", path)
93 } else {
94 virtualFsLog.Printf("Frontmatter cache stored: path=%s", path)
95 }
96 cached, ok := actual.(*FrontmatterResult)
97 if !ok {
98 virtualFsLog.Printf("Frontmatter cache type mismatch for %s: got %T", path, actual)
99 builtinFrontmatterCache.Store(path, result)
100 return result
101 }
102 return cached
103}
104
105// BuiltinPathPrefix is the path prefix used for embedded builtin files.
106// Paths with this prefix bypass filesystem resolution and security checks.

Callers 1

Calls 1

PrintfMethod · 0.45

Tested by

no test coverage detected