Skip to content

Introduce dependency-aware cache invalidation system #311

@Draggu

Description

@Draggu

Expert currently maintains several independent state and cache components, such as Forge.Document.Store and Engine.ModuleMappings. Currently, invalidating or updating an entry in one cache could potentially leave related entries in other parts of the system outdated, especially in cases where cached data is derived transitively. In some cases, this can lead to stale or inconsistent results when cached data is derived transitively from other cached values.

This idea is inspired by salsa.rs, which provides a framework for tracking dependencies between cached values and automatically propagating invalidations.
A more centralized or coordinated approach could help the Expert handle cache consistency more reliably. In particular, it may be useful to:

  • explicitly track dependencies between cached entries
  • ensure that when a cache entry is invalidated or updated, any dependent entries are also invalidated

While not directly part of task #303 (the cache backend rewrite from ETS to SQLite), that work should be taken into consideration when designing this system.
Additionally, this mechanism could be extended to include telemetry, providing insights into cache usage, hit/miss rates, and invalidation propagation.

It might also be worthwhile to identify which caches and dependency relationships would benefit most from being included in such a mechanism.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions