Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(event cache): write updates from the event cache to storage #4347

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Nov 28, 2024

This is one direction1 of interacting between the event cache and the storage backend. I think this is fine design… as long as we don't have any other process writing into the cache, in which case we'll need to reset at different boundaries.

The main idea in this PR is to use RoomEventCacheState::with_events_mut(func: impl FnMut(&mut RoomEvents)) to perform any write to the underlying RoomEvent data structure. The function takes care of maintaining the storage, after updates have been performed.

Additionally: this behavior isn't enabled by default; callers have to call EventCache::enable_storage() when they start using the event cache.

I've put the RoomEventCacheState data structure in a private module, so that even the same module can't access its private fields, and we don't make mistakes by accidentally misusing events.

Part of #3280. Split and reworked from #4308.

Footnotes

  1. not the band

@bnjbvr bnjbvr requested a review from a team as a code owner November 28, 2024 11:55
@bnjbvr bnjbvr requested review from stefanceriu and Hywan and removed request for a team and stefanceriu November 28, 2024 11:55
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 90.66667% with 7 lines in your changes missing coverage. Please review.

Project coverage is 85.13%. Comparing base (e1f0037) to head (884bb5c).

Files with missing lines Patch % Lines
crates/matrix-sdk/src/event_cache/pagination.rs 82.60% 4 Missing ⚠️
crates/matrix-sdk/src/event_cache/mod.rs 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4347      +/-   ##
==========================================
+ Coverage   85.10%   85.13%   +0.02%     
==========================================
  Files         280      280              
  Lines       30562    30595      +33     
==========================================
+ Hits        26010    26046      +36     
+ Misses       4552     4549       -3     

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

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.

1 participant