Skip to content

Commit fb21d8f

Browse files
committed
feat(base): MemoryStore uses RelationalLinkedChunk to store events.
That's it.
1 parent 99a17fd commit fb21d8f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use std::{collections::HashMap, num::NonZeroUsize, sync::RwLock as StdRwLock, ti
1616

1717
use async_trait::async_trait;
1818
use matrix_sdk_common::{
19-
linked_chunk::Update, ring_buffer::RingBuffer,
19+
linked_chunk::{relational::RelationalLinkedChunk, Update},
20+
ring_buffer::RingBuffer,
2021
store_locks::memory_store_helper::try_take_leased_lock,
2122
};
2223
use ruma::{MxcUri, OwnedMxcUri};
@@ -35,6 +36,7 @@ use crate::{
3536
pub struct MemoryStore {
3637
media: StdRwLock<RingBuffer<(OwnedMxcUri, String /* unique key */, Vec<u8>)>>,
3738
leases: StdRwLock<HashMap<String, (String, Instant)>>,
39+
events: StdRwLock<RelationalLinkedChunk<Event, Gap>>,
3840
}
3941

4042
// SAFETY: `new_unchecked` is safe because 20 is not zero.
@@ -45,6 +47,7 @@ impl Default for MemoryStore {
4547
Self {
4648
media: StdRwLock::new(RingBuffer::new(NUMBER_OF_MEDIAS)),
4749
leases: Default::default(),
50+
events: StdRwLock::new(RelationalLinkedChunk::new()),
4851
}
4952
}
5053
}
@@ -72,9 +75,11 @@ impl EventCacheStore for MemoryStore {
7275

7376
async fn handle_linked_chunk_updates(
7477
&self,
75-
_updates: &[Update<Event, Gap>],
78+
updates: &[Update<Event, Gap>],
7679
) -> Result<(), Self::Error> {
77-
todo!()
80+
self.events.write().unwrap().apply_updates(updates);
81+
82+
Ok()
7883
}
7984

8085
async fn add_media_content(

0 commit comments

Comments
 (0)