improvement: better sqlite
This commit is contained in:
parent
a4310f840e
commit
2c3bee34a0
3 changed files with 47 additions and 18 deletions
|
@ -92,13 +92,17 @@ pub struct Rooms {
|
|||
pub(super) pdu_cache: Mutex<LruCache<EventId, Arc<PduEvent>>>,
|
||||
pub(super) auth_chain_cache: Mutex<LruCache<u64, HashSet<u64>>>,
|
||||
pub(super) shorteventid_cache: Mutex<LruCache<u64, EventId>>,
|
||||
pub(super) stateinfo_cache: Mutex<LruCache<u64,
|
||||
Vec<(
|
||||
u64, // sstatehash
|
||||
HashSet<CompressedStateEvent>, // full state
|
||||
HashSet<CompressedStateEvent>, // added
|
||||
HashSet<CompressedStateEvent>, // removed
|
||||
)>>>,
|
||||
pub(super) stateinfo_cache: Mutex<
|
||||
LruCache<
|
||||
u64,
|
||||
Vec<(
|
||||
u64, // sstatehash
|
||||
HashSet<CompressedStateEvent>, // full state
|
||||
HashSet<CompressedStateEvent>, // added
|
||||
HashSet<CompressedStateEvent>, // removed
|
||||
)>,
|
||||
>,
|
||||
>,
|
||||
}
|
||||
|
||||
impl Rooms {
|
||||
|
@ -414,7 +418,8 @@ impl Rooms {
|
|||
HashSet<CompressedStateEvent>, // removed
|
||||
)>,
|
||||
> {
|
||||
if let Some(r) = self.stateinfo_cache
|
||||
if let Some(r) = self
|
||||
.stateinfo_cache
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_mut(&shortstatehash)
|
||||
|
@ -458,10 +463,6 @@ impl Rooms {
|
|||
|
||||
response.push((shortstatehash, state, added, removed));
|
||||
|
||||
self.stateinfo_cache
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(shortstatehash, response.clone());
|
||||
Ok(response)
|
||||
} else {
|
||||
let mut response = Vec::new();
|
||||
|
@ -1173,6 +1174,9 @@ impl Rooms {
|
|||
|
||||
let sync_pdu = pdu.to_sync_room_event();
|
||||
|
||||
let mut notifies = Vec::new();
|
||||
let mut highlights = Vec::new();
|
||||
|
||||
for user in db
|
||||
.rooms
|
||||
.room_members(&pdu.room_id)
|
||||
|
@ -1218,11 +1222,11 @@ impl Rooms {
|
|||
userroom_id.extend_from_slice(pdu.room_id.as_bytes());
|
||||
|
||||
if notify {
|
||||
self.userroomid_notificationcount.increment(&userroom_id)?;
|
||||
notifies.push(userroom_id.clone());
|
||||
}
|
||||
|
||||
if highlight {
|
||||
self.userroomid_highlightcount.increment(&userroom_id)?;
|
||||
highlights.push(userroom_id);
|
||||
}
|
||||
|
||||
for senderkey in db.pusher.get_pusher_senderkeys(&user) {
|
||||
|
@ -1230,6 +1234,11 @@ impl Rooms {
|
|||
}
|
||||
}
|
||||
|
||||
self.userroomid_notificationcount
|
||||
.increment_batch(&mut notifies.into_iter())?;
|
||||
self.userroomid_highlightcount
|
||||
.increment_batch(&mut highlights.into_iter())?;
|
||||
|
||||
match pdu.kind {
|
||||
EventType::RoomRedaction => {
|
||||
if let Some(redact_id) = &pdu.redacts {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue