Skip to content

Conversation

@mgoldenberg
Copy link
Contributor

Background

This pull request is part of a series of pull requests to add a full IndexedDB implementation of the EventCacheStore (see #4617, #4996, #5090, #5138, #5226, #5274). This particular pull request focuses on providing implementations of a few EventCacheStore functions.

Changes

The primary change is the addition of a top-level type, IndexeddbEventCacheStore, as well as a way of constructing this type through IndexeddbEventCacheStoreBuilder. Additionally, IndexeddbEventCacheStore also provides an implementation of EventCacheStore.

In order to limit the size of this pull request, the implementation of EventCacheStore is almost entirely delegated to a nested MemoryStore except for the following two functions, which have a genuine IndexedDB implementation.

  • EventCacheStore::handle_linked_chunk_updates
  • EventCacheStore::load_all_chunks

Additionally, there are a number of additions to IndexeddbEventCacheStoreTransaction which support the implementation of the EventCacheStore functions above.

  • get_chunk_by_id
  • get_chunks_in_room
  • load_chunk_by_id
  • add_chunk
  • delete_chunk_by_id
  • delete_chunks_in_room
  • get_events_by_position
  • get_events_by_chunk
  • put_event
  • delete_events_by_position
  • delete_event_by_position
  • delete_events_by_chunk
  • delete_events_by_chunk_from_index
  • delete_events_in_room
  • get_gap_by_id
  • delete_gap_by_id
  • delete_gaps_in_room

These are mostly typed wrappers around the generic functions in IndexeddbEventCacheStoreTransaction, though some of them add extra functionality as well.

Tests

A quick note about the tests. Because most of the functions are delegated to a nested MemoryStore and only two are actually implemented, the event_cache_store_integration_tests macro will generate many failures. Consequently, I have made a local copy of the macro which only includes tests which are relevant to EventCacheStore::handle_linked_chunk_updates and EventCacheStore::load_all_chunks. Once all functionality is added, this local macro will disappear and I will use the original one from matrix_sdk_base.

Additionally, there are a number of tests which have been copied and adapted from SQLite implementation of EventCacheStore. Many of these tests will likely be generalized and included as part of the event_cache_store_integration_tests macro and will also, hopefully, disappear (see #5342).

Future Work

  • Add remaining implementations of EventCacheStore functions without relying on MemoryStore.

  • Public API changes documented in changelogs (optional)

Signed-off-by: Michael Goldenberg [email protected]

@mgoldenberg mgoldenberg changed the title Indexeddb event cache store handle linked chunk updates IndexedDB: Add initial implementation of EventCacheStore Jul 2, 2025
@mgoldenberg mgoldenberg marked this pull request as ready for review July 2, 2025 19:47
@mgoldenberg mgoldenberg requested a review from a team as a code owner July 2, 2025 19:47
@mgoldenberg mgoldenberg requested review from Hywan and removed request for a team July 2, 2025 19:47
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Just awesome. Well done!

@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.76%. Comparing base (40e3cd3) to head (a1f34a9).
Report is 35 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5343      +/-   ##
==========================================
- Coverage   88.77%   88.76%   -0.01%     
==========================================
  Files         334      334              
  Lines       91086    91086              
  Branches    91086    91086              
==========================================
- Hits        80860    80851       -9     
- Misses       6387     6396       +9     
  Partials     3839     3839              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mgoldenberg mgoldenberg force-pushed the indexeddb-event-cache-store-handle-linked-chunk-updates branch from 7752d32 to f4cc0c7 Compare July 9, 2025 02:13
@mgoldenberg mgoldenberg force-pushed the indexeddb-event-cache-store-handle-linked-chunk-updates branch from f4cc0c7 to a1f34a9 Compare July 9, 2025 02:14
@mgoldenberg
Copy link
Contributor Author

Oops! Forgot to autosquash when rebasing, so did it a second time!

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