diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index b9c0d7ba..dfcfedea 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -1,7 +1,7 @@ mod data; use std::{ - collections::{BTreeMap, HashMap, HashSet}, + collections::{BTreeMap, HashSet}, sync::Arc, }; @@ -27,12 +27,12 @@ use ruma::{ push::{Action, Ruleset, Tweak}, serde::Base64, state_res::{self, Event, RoomVersion}, - uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId, OwnedServerName, - RoomId, RoomVersionId, ServerName, UserId, + uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedServerName, RoomId, + RoomVersionId, ServerName, UserId, }; use serde::Deserialize; use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; -use tokio::sync::{Mutex, RwLock}; +use tokio::sync::RwLock; use crate::{ admin, @@ -66,15 +66,12 @@ struct ExtractBody { pub struct Service { db: Data, - - pub lasttimelinecount_cache: Mutex>, } impl Service { pub fn build(_server: &Arc, db: &Arc) -> Result { Ok(Self { db: Data::new(db), - lasttimelinecount_cache: Mutex::new(HashMap::new()), }) } diff --git a/src/service/services.rs b/src/service/services.rs index 70e6a6d5..81aba231 100644 --- a/src/service/services.rs +++ b/src/service/services.rs @@ -95,10 +95,7 @@ impl Services { let lasttimelinecount_cache = self .rooms .timeline - .lasttimelinecount_cache - .lock() - .await - .len(); + .get_lasttimelinecount_cache_usage().0; let roomid_spacehierarchy_cache = self .rooms .spaces @@ -177,10 +174,7 @@ bad_signature_ratelimiter: {bad_signature_ratelimiter} if amount > 4 { self.rooms .timeline - .lasttimelinecount_cache - .lock() - .await - .clear(); + .clear_lasttimelinecount_cache(); } if amount > 5 { self.rooms