Skip to content

Commit 524040b

Browse files
committed
refactor(event cache): have EventCacheStore::clear_all_rooms_chunks delete all the events' contents
1 parent 0227b3f commit 524040b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

benchmarks/benches/room_bench.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ pub fn load_pinned_events_benchmark(c: &mut Criterion) {
173173
assert_eq!(pinned_event_ids.len(), PINNED_EVENTS_COUNT);
174174

175175
// Reset cache so it always loads the events from the mocked endpoint
176-
// TODO: allow clearing the events table?
177-
//client.event_cache().empty_immutable_cache().await;
176+
client
177+
.event_cache_store()
178+
.lock()
179+
.await
180+
.unwrap()
181+
.clear_all_rooms_chunks()
182+
.await
183+
.unwrap();
178184

179185
let timeline = Timeline::builder(&room)
180186
.with_focus(TimelineFocus::PinnedEvents {

crates/matrix-sdk-base/src/event_cache/store/traits.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ pub trait EventCacheStore: AsyncTraitDeps {
9898
/// Clear persisted events for all the rooms.
9999
///
100100
/// This will empty and remove all the linked chunks stored previously,
101-
/// using the above [`Self::handle_linked_chunk_updates`] methods.
101+
/// using the above [`Self::handle_linked_chunk_updates`] methods. It
102+
/// must *also* delete all the events' content, if they were stored in a
103+
/// separate table.
102104
async fn clear_all_rooms_chunks(&self) -> Result<(), Self::Error>;
103105

104106
/// Given a set of event IDs, return the duplicated events along with their

crates/matrix-sdk-sqlite/src/event_cache_store.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,9 @@ impl EventCacheStore for SqliteEventCacheStore {
863863
.await?
864864
.with_transaction(move |txn| {
865865
// Remove all the chunks, and let cascading do its job.
866-
txn.execute("DELETE FROM linked_chunks", ())
866+
txn.execute("DELETE FROM linked_chunks", ())?;
867+
// Also clear all the events' contents.
868+
txn.execute("DELETE FROM events", ())
867869
})
868870
.await?;
869871
Ok(())

0 commit comments

Comments
 (0)