Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent retention of cached object reference across async boundary #195

Closed

Conversation

lorefnon
Copy link
Contributor

@lorefnon lorefnon commented Jan 19, 2024

@lorefnon lorefnon force-pushed the ref-async-boundary-retention-fix branch from 6f66707 to d84002e Compare January 19, 2024 14:19
@@ -96,21 +96,25 @@ impl<T: AsyncFromStrWithState> FileCache<T> {
}

pub async fn get(&self, app_state: &AppState, path: &PathBuf) -> anyhow::Result<Arc<T>> {
log::trace!("Attempting to get from cache {:?}", path);
if let Some(cached) = self.cache.read().await.get(path) {
if let Some(cached) = self.cache.get(path) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just need to clone the result of self.cache.get before if..let here.

@lovasoa lovasoa closed this Jan 30, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants