From df87709d1f6560d78849366a74251c480bb33899 Mon Sep 17 00:00:00 2001 From: evenyag Date: Fri, 29 Dec 2023 00:27:34 +0800 Subject: [PATCH] feat: update cache --- src/mito2/src/cache/file_cache.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mito2/src/cache/file_cache.rs b/src/mito2/src/cache/file_cache.rs index 2ead0e744742..a0beb83bcb1d 100644 --- a/src/mito2/src/cache/file_cache.rs +++ b/src/mito2/src/cache/file_cache.rs @@ -113,7 +113,7 @@ impl FileCache { return None; } - let file_path = cache_file_path(&self.file_dir, key); + let file_path = self.cache_file_path(key); match self.local_store.reader(&file_path).await { Ok(reader) => { CACHE_HIT.with_label_values(&[FILE_TYPE]).inc(); @@ -133,7 +133,7 @@ impl FileCache { /// Removes a file from the cache explicitly. pub(crate) async fn remove(&self, key: IndexKey) { - let file_path = cache_file_path(&self.file_dir, key); + let file_path = self.cache_file_path(key); if let Err(e) = self.local_store.delete(&file_path).await { warn!(e; "Failed to delete a cached file {}", file_path); } @@ -179,6 +179,16 @@ impl FileCache { Ok(()) } + + /// Returns the cache file path for the key. + pub(crate) fn cache_file_path(&self, key: IndexKey) -> String { + cache_file_path(&self.file_dir, key) + } + + /// Returns the local store of the file cache. + pub(crate) fn local_store(&self) -> ObjectStore { + self.local_store.clone() + } } /// Key of file cache index.