Skip to content

Commit

Permalink
feat(base): MemoryStore uses RelationalLinkedChunk to store events.
Browse files Browse the repository at this point in the history
That's it.
  • Loading branch information
Hywan committed Nov 20, 2024
1 parent 8c45f84 commit c9da411
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/matrix-sdk-base/src/event_cache/store/memory_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use std::{collections::HashMap, num::NonZeroUsize, sync::RwLock as StdRwLock, ti

use async_trait::async_trait;
use matrix_sdk_common::{
linked_chunk::Update, ring_buffer::RingBuffer,
linked_chunk::{relational::RelationalLinkedChunk, Update},
ring_buffer::RingBuffer,
store_locks::memory_store_helper::try_take_leased_lock,
};
use ruma::{MxcUri, OwnedMxcUri};
Expand All @@ -35,6 +36,7 @@ use crate::{
pub struct MemoryStore {
media: StdRwLock<RingBuffer<(OwnedMxcUri, String /* unique key */, Vec<u8>)>>,
leases: StdRwLock<HashMap<String, (String, Instant)>>,
events: StdRwLock<RelationalLinkedChunk<Event, Gap>>,
}

// SAFETY: `new_unchecked` is safe because 20 is not zero.
Expand All @@ -45,6 +47,7 @@ impl Default for MemoryStore {
Self {
media: StdRwLock::new(RingBuffer::new(NUMBER_OF_MEDIAS)),
leases: Default::default(),
events: StdRwLock::new(RelationalLinkedChunk::new()),
}
}
}
Expand Down Expand Up @@ -74,7 +77,7 @@ impl EventCacheStore for MemoryStore {
&self,
_updates: &[Update<Event, Gap>],
) -> Result<(), Self::Error> {
todo!()
Ok(self.events.write().unwrap().apply_updates(updates))
}

async fn add_media_content(
Expand Down

0 comments on commit c9da411

Please sign in to comment.