Skip to content

Integrate metadata validation in Cache.Has to detect template disk changes #6515

@coderabbitai

Description

@coderabbitai

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

Metadata

Metadata

Assignees

Labels

Type: EnhancementMost issues will probably ask for additions or changes.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions