Skip to content

Configuration Caching

netherframe uses lightweight, in-process caching to avoid recomputing resource configuration during synthesis. The current approach is intentionally simple: it does not rely on hashing and it does not reuse synthesis output between runs.

Overview

Caching is scoped to a single process and focuses on memoizing _to_config() results for resources, providers, outputs, and variables. The cache is keyed by resource identity plus a version counter that increments when the resource changes.

How It Works

Version Tracking

Each tracked construct has a version counter that increments when attributes are assigned. The stack keeps a cache of computed configs alongside the version they were built from.

Cache Invalidation

When an attribute changes:

  1. The construct version increments
  2. Cached config for that construct is cleared
  3. The next synthesis recomputes the config

Nested mutations (for example, modifying a list or dict in-place) do not trigger __setattr__. Reassign the field or call _invalidate_resource_cache() to ensure the cache rebuilds.

Automatic Behavior

Caching is always enabled and requires no configuration. It is intended to keep single-pass synthesis fast while avoiding the overhead of hash computation.

Best Practices

  1. Reassign nested structures after mutation (e.g., resource.tags = new_tags)
  2. Call _invalidate_resource_cache(resource) after complex in-place updates
  3. Avoid relying on cross-run caching; it is not persisted

Limitations

  • Cache is memory-only and does not persist between processes
  • In-place mutations of nested structures require explicit invalidation