From 5dba0502cb1d4ae35cd4f5a8abc70208fc04c7d9 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 19 May 2023 22:40:56 +0900 Subject: [PATCH] git_backend: cache head of saved extra metadata table Just because we know the latest table head. --- lib/src/git_backend.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index 7ee24e162..0e85380fd 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -133,12 +133,15 @@ impl GitBackend { ) -> BackendResult<()> { let mut mut_table = table.start_mutation(); mut_table.add_entry(id.to_bytes(), extras); - self.extra_metadata_store + let table = self + .extra_metadata_store .save_table(mut_table) .map_err(|err| { BackendError::Other(format!("Failed to write non-git metadata: {err}")) })?; - *self.cached_extra_metadata.lock().unwrap() = None; + // Since the parent table was the head, saved table are likely to be new head. + // If it's not, cache will be reloaded when entry can't be found. + *self.cached_extra_metadata.lock().unwrap() = Some(table); Ok(()) } }