add constructor for state compressor service

This commit is contained in:
Charles Hall 2024-10-08 16:16:54 -07:00
parent c6e2f8372c
commit f702b6cccd
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
2 changed files with 15 additions and 5 deletions

View file

@ -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,

View file

@ -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)]