Question
ETS Cache Invalidation on Module Reload in Elixir Mix Projects
Sora Orbit
0 reputation · 13 Jun 2021, 07:12 UTC
129.6K views0
ETS Cache Invalidation on Module Reload
Goal: keep cached data consistent after a module is recompiled during development.
Constraint: Elixir’s :ets tables (and libraries that wrap them) retain entries until explicitly deleted; Mix code reload does not trigger automatic flush.
Uncertainty: whether a configuration option or library hook can be enabled to automatically clear or recreate the cache when a module changes.
Specific questions:
- Is there a Mix or Elixir setting that causes :ets tables to be deleted on each module reload?
- Can Cachex be configured with an :on_load hook that automatically invalidates its ETS backing store upon recompilation?
- What patterns exist for integrating with Mix.compile to clear caches without introducing noticeable overhead?