Skip to content

fix(stores): add caching to CliSettings.load() - #797

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/code-quality/cli-settings-caching-v2
Open

fix(stores): add caching to CliSettings.load()#797
github-actions[bot] wants to merge 1 commit into
mainfrom
fix/code-quality/cli-settings-caching-v2

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Add a class-level cache to CliSettings.load() to avoid repeated disk I/O when loading CLI settings. This addresses the performance issue where settings were being read from disk on every call.

Changes

  • Add _cache: ClassVar[dict[Path, CliSettings]] class attribute to store cached settings
  • Cache is keyed by config path, allowing different paths (e.g., in tests) to have their own cache entries
  • load() now returns cached value if available (unless refresh=True)
  • save() updates the cache after writing to disk
  • Add clear_cache(path=None) method to clear all or specific cache entries

Related Issue

Addresses findings from #795 (Item 8: Add caching to CliSettings.load())

Testing

  • Linting passes (make lint)
  • All 1361 tests pass (make test)

This PR was automatically generated by the Code Quality Report workflow.

Add a class-level cache (keyed by config path) to avoid repeated disk I/O
when loading CLI settings. The cache:

- Uses config path as key to handle mocked paths in tests
- Is updated when save() is called
- Can be explicitly cleared via clear_cache()
- Supports refresh=True parameter to force reload

Addresses item from code quality report.

Closes #795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants