-
-
Notifications
You must be signed in to change notification settings - Fork 127
perf: granular cache patching instead of invalidate+refetch #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,7 +231,13 @@ impl<'a> Groups<'a> { | |
| .client | ||
| .execute(AddParticipantsIq::new(jid, participants)) | ||
| .await?; | ||
| self.client.get_group_cache().await.invalidate(jid).await; | ||
| // Patch cache with the participants we just added (no phone_number known here) | ||
| let group_cache = self.client.get_group_cache().await; | ||
| if let Some(mut info) = group_cache.get(jid).await { | ||
| let new: Vec<_> = participants.iter().map(|p| (p.clone(), None)).collect(); | ||
| info.add_participants(&new); | ||
| group_cache.insert(jid.clone(), info).await; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serialize group cache patching per group. This is a non-atomic As per coding guidelines, Also applies to: 254-258 🤖 Prompt for AI Agents |
||
| } | ||
| Ok(result) | ||
| } | ||
|
|
||
|
|
@@ -244,7 +250,13 @@ impl<'a> Groups<'a> { | |
| .client | ||
| .execute(RemoveParticipantsIq::new(jid, participants)) | ||
| .await?; | ||
| self.client.get_group_cache().await.invalidate(jid).await; | ||
| // Patch cache by filtering out removed participants | ||
| let group_cache = self.client.get_group_cache().await; | ||
| if let Some(mut info) = group_cache.get(jid).await { | ||
| let users: Vec<&str> = participants.iter().map(|p| p.user.as_str()).collect(); | ||
| info.remove_participants(&users); | ||
| group_cache.insert(jid.clone(), info).await; | ||
| } | ||
| Ok(result) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.