diff --git a/src/service.rs b/src/service.rs index b5f356aa..07a48520 100644 --- a/src/service.rs +++ b/src/service.rs @@ -153,17 +153,17 @@ impl Services { }, ), state_cache: rooms::state_cache::Service::new(db), - state_compressor: rooms::state_compressor::Service { + state_compressor: rooms::state_compressor::Service::new( db, #[allow( clippy::as_conversions, clippy::cast_sign_loss, clippy::cast_possible_truncation )] - stateinfo_cache: StdMutex::new(LruCache::new( - (100.0 * config.cache_capacity_modifier) as usize, - )), - }, + { + (100.0 * config.cache_capacity_modifier) as usize + }, + ), timeline: rooms::timeline::Service::new( db, config.pdu_cache_capacity, diff --git a/src/service/rooms/state_compressor.rs b/src/service/rooms/state_compressor.rs index 4232a325..cac73fe0 100644 --- a/src/service/rooms/state_compressor.rs +++ b/src/service/rooms/state_compressor.rs @@ -72,6 +72,16 @@ impl CompressedStateEvent { } impl Service { + pub(crate) fn new( + db: &'static dyn Data, + stateinfo_cache_size: usize, + ) -> Self { + Self { + db, + stateinfo_cache: Mutex::new(LruCache::new(stateinfo_cache_size)), + } + } + /// Returns a stack with info on shortstatehash, full state, added diff and /// removed diff for the selected shortstatehash and each parent layer. #[allow(clippy::type_complexity)]