Skip to content

Cache todo links index by todo/note version signals#887

Merged
multiplex55 merged 1 commit intomasterfrom
codex/add-cached-index-path-for-todo-links
Feb 17, 2026
Merged

Cache todo links index by todo/note version signals#887
multiplex55 merged 1 commit intomasterfrom
codex/add-cached-index-path-for-todo-links

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Reduce repeated work rebuilding the notes+links index on every todo links query by caching the computed (notes, index) when source data hasn't changed.
  • Ensure the cached index is invalidated when todos or notes change so query results stay correct.
  • Provide a way to observe rebuilds from tests to verify caching behavior.

Description

  • Added a small cache type TodoLinksIndexCache and a process-wide TODO_LINKS_INDEX_CACHE keyed by (todo_version(), note_version()) to store notes and the LinkIndex in src/plugins/todo.rs.
  • Introduced get_todo_links_index() which returns a cached (notes, index) when versions match and otherwise rebuilds the index and updates the cache while incrementing TODO_LINKS_INDEX_REBUILD_COUNT.
  • Wired cache invalidation into existing todo update paths by calling invalidate_todo_links_index_cache() from update_cache() and the file-watcher closure so watcher-triggered updates also clear the cache.
  • Replaced the inline index rebuild in the todo links query path with a call to get_todo_links_index() and added a unit test todo_links_reuses_cached_index_between_queries that asserts rebuild count behavior.

Testing

  • Ran cargo fmt -- src/plugins/todo.rs which completed successfully.
  • Added unit test todo_links_reuses_cached_index_between_queries exercising cache reuse and invalidation behavior and confirmed it is present in the test suite.
  • Attempted to run the targeted test (todo_links_reuses_cached_index_between_queries), but cargo test failed in this environment due to a missing system dependency required by alsa-sys (missing alsa.pc), so the test could not be executed here.

Codex Task

@multiplex55 multiplex55 merged commit a9bdfd7 into master Feb 17, 2026
1 check failed
@multiplex55 multiplex55 deleted the codex/add-cached-index-path-for-todo-links branch February 20, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant