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)
| 87 | // (or its contained maps/slices) after this call. |
| 88 | // Uses LoadOrStore so concurrent races are safe; the winning value is returned. |
| 89 | func 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. |
no test coverage detected