From b35d8d3e108905a908ad86d51a365f1d40bc8549 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 7 Feb 2023 15:13:07 +0800 Subject: [PATCH] improve the code --- src/object-store/src/cache_policy.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/object-store/src/cache_policy.rs b/src/object-store/src/cache_policy.rs index ce986bad85e2..89919bb6a582 100644 --- a/src/object-store/src/cache_policy.rs +++ b/src/object-store/src/cache_policy.rs @@ -25,11 +25,9 @@ use opendal::raw::{Accessor, RpDelete, RpRead}; use opendal::{ErrorKind, OpDelete, OpRead, OpWrite, Result}; use tokio::sync::Mutex; -struct LruValue; - #[derive(Debug)] pub struct LruCachePolicy { - lru_cache: Arc>>, + lru_cache: Arc>>, } impl LruCachePolicy { @@ -63,7 +61,7 @@ impl CachePolicy for LruCachePolicy { Ok(v) => { // update lru when cache hit let mut lru_cache = lru_cache.lock().await; - lru_cache.get_or_insert(cache_path.clone(), || LruValue {}); + lru_cache.get_or_insert(cache_path.clone(), || ()); Ok(v) } Err(err) if err.kind() == ErrorKind::ObjectNotFound => { @@ -77,7 +75,7 @@ impl CachePolicy for LruCachePolicy { let r = { // push new cache file name to lru let mut lru_cache = lru_cache.lock().await; - lru_cache.push(cache_path.clone(), LruValue {}) + lru_cache.push(cache_path.clone(), ()) }; // delete the evicted cache file if let Some((k, _v)) = r {