Skip to content

try_get_with_by_ref always triggers init future #206

Answered by tatsuya6502
dannygale asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for reporting. I reviewed your original code, and I believe you have an extra .await, which causes the async block executed unconditionally before being passed to try_get_with_by_ref(). Please remove it.

        let metadata = self
            .mdcache
            .try_get_with_by_ref(
                &key,
                async {
                    tracing::debug!(
                        "mdcache miss ({})",
                        if self.mdcache.contains_key(&key) {
                            "NOT expected"
                        } else {
                            "expected"
                        },
                    );
                    self.file.read_metadata()

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@tatsuya6502
Comment options

Comment options

You must be logged in to vote
1 reply
@tatsuya6502
Comment options

Answer selected by tatsuya6502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants