Skip to content

fix: update cache in-memory state after write operations#47

Draft
notJoon wants to merge 2 commits intododok8:mainfrom
notJoon:fix/cache-in-memory-state
Draft

fix: update cache in-memory state after write operations#47
notJoon wants to merge 2 commits intododok8:mainfrom
notJoon:fix/cache-in-memory-state

Conversation

@notJoon
Copy link
Copy Markdown

@notJoon notJoon commented Feb 15, 2026

Summary

Cache set/remove/clear methods did not update in-memory state after writing to disk, causing stale reads within the same process. This PR fixes the inconsistency and adds regression tests.

Changes

  • Change set, remove, clear signatures from &self to &mut self so in-memory state can be mutated
  • Apply write-then-commit pattern: build new state, write to disk, update memory only on success to prevent memory/disk divergence on I/O failure
  • Propagate &mut self requirement to callers in fetcher, generator, main, init, and watcher
  • Add test_cache_set_visible_immediately_in_same_process and test_cache_remove_visible_immediately_in_same_process regression tests

Related Issues

None

Checklist

  • cargo test --all-features passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo fmt --all --check passes
  • Updated documentation if needed
  • Added tests for new functionality

@notJoon notJoon marked this pull request as draft February 15, 2026 07:10
@dodok8
Copy link
Copy Markdown
Owner

dodok8 commented Feb 16, 2026

As #52 is merged, it made large changes to the main branch. I recommend merge main branch again.

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.

2 participants