mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
add constructor for state accessor service
This commit is contained in:
parent
a083ff9200
commit
c6e2f8372c
2 changed files with 27 additions and 12 deletions
|
|
@ -133,25 +133,25 @@ impl Services {
|
|||
state: rooms::state::Service {
|
||||
db,
|
||||
},
|
||||
state_accessor: rooms::state_accessor::Service {
|
||||
state_accessor: rooms::state_accessor::Service::new(
|
||||
db,
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
server_visibility_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
{
|
||||
(100.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
#[allow(
|
||||
clippy::as_conversions,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation
|
||||
)]
|
||||
user_visibility_cache: StdMutex::new(LruCache::new(
|
||||
(100.0 * config.cache_capacity_modifier) as usize,
|
||||
)),
|
||||
},
|
||||
{
|
||||
(100.0 * config.cache_capacity_modifier) as usize
|
||||
},
|
||||
),
|
||||
state_cache: rooms::state_cache::Service::new(db),
|
||||
state_compressor: rooms::state_compressor::Service {
|
||||
db,
|
||||
|
|
|
|||
|
|
@ -38,14 +38,29 @@ mod data;
|
|||
pub(crate) use data::Data;
|
||||
|
||||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
pub(crate) server_visibility_cache:
|
||||
db: &'static dyn Data,
|
||||
server_visibility_cache:
|
||||
Mutex<LruCache<(OwnedServerName, ShortStateHash), bool>>,
|
||||
pub(crate) user_visibility_cache:
|
||||
Mutex<LruCache<(OwnedUserId, ShortStateHash), bool>>,
|
||||
user_visibility_cache: Mutex<LruCache<(OwnedUserId, ShortStateHash), bool>>,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
pub(crate) fn new(
|
||||
db: &'static dyn Data,
|
||||
server_visibility_cache_size: usize,
|
||||
user_visibility_cache_size: usize,
|
||||
) -> Self {
|
||||
Self {
|
||||
db,
|
||||
server_visibility_cache: Mutex::new(LruCache::new(
|
||||
server_visibility_cache_size,
|
||||
)),
|
||||
user_visibility_cache: Mutex::new(LruCache::new(
|
||||
user_visibility_cache_size,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a StateMap by iterating over all keys that start
|
||||
/// with state_hash, this gives the full state for the given state_hash.
|
||||
#[tracing::instrument(skip(self))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue