mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
move shortstatekey_cache to service
This commit is contained in:
parent
190b788683
commit
d3b62e598d
4 changed files with 35 additions and 35 deletions
|
|
@ -4,7 +4,6 @@ use ruma::{events::StateEventType, EventId, RoomId};
|
|||
|
||||
use crate::{
|
||||
database::KeyValueDatabase,
|
||||
observability::{FoundIn, Lookup, METRICS},
|
||||
service::{
|
||||
self,
|
||||
rooms::short::{
|
||||
|
|
@ -130,15 +129,6 @@ impl service::rooms::short::Data for KeyValueDatabase {
|
|||
&self,
|
||||
shortstatekey: ShortStateKey,
|
||||
) -> Result<(StateEventType, String)> {
|
||||
let lookup = Lookup::ShortToStateKey;
|
||||
|
||||
if let Some(id) =
|
||||
self.shortstatekey_cache.lock().unwrap().get_mut(&shortstatekey)
|
||||
{
|
||||
METRICS.record_lookup(lookup, FoundIn::Cache);
|
||||
return Ok(id.clone());
|
||||
}
|
||||
|
||||
let bytes = self
|
||||
.shortstatekey_statekey
|
||||
.get(&shortstatekey.get().to_be_bytes())?
|
||||
|
|
@ -168,16 +158,7 @@ impl service::rooms::short::Data for KeyValueDatabase {
|
|||
)
|
||||
})?;
|
||||
|
||||
let result = (event_type, state_key);
|
||||
|
||||
METRICS.record_lookup(lookup, FoundIn::Database);
|
||||
|
||||
self.shortstatekey_cache
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(shortstatekey, result.clone());
|
||||
|
||||
Ok(result)
|
||||
Ok((event_type, state_key))
|
||||
}
|
||||
|
||||
/// Returns `(shortstatehash, already_existed)`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue