-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Problem
In SDK use cases where a single Parser
instance remains active for an extended period, templates on disk may change while the parser continues to use cached copies. Currently, the parsedTemplate
and compiledTemplate
caches are populated during the first call to (*Parser).ParseTemplate
and remain in memory for the parser's lifetime. These caches return cached copies even if the file on disk changes, unless the update process runs mid-execution or something explicitly invalidates/purges the cache.
No calls to (parsed|compiled)Template.Purge()
are currently present in the codebase to handle this scenario.
Proposed Solution
Integrate a minimal/quick metadata validation layer into Cache.Has
that:
- Stays fast but better handles disk changes
- Avoids forcing a full template reload
- Validates template metadata efficiently to detect changes
This would allow the cache to remain performant while properly invalidating entries when the underlying template files are modified.
Context
- Related PR: perf(loader): reuse cached parsed templates #6504
- Discussion: perf(loader): reuse cached parsed templates #6504 (comment)
- Requested by: @dwisiswant0