Skip to content

Commit

Permalink
improve the code
Browse files Browse the repository at this point in the history
  • Loading branch information
e1ijah1 committed Feb 7, 2023
1 parent 20a0ddc commit b35d8d3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/object-store/src/cache_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mutex<LruCache<String, LruValue>>>,
lru_cache: Arc<Mutex<LruCache<String, ()>>>,
}

impl LruCachePolicy {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 {
Expand Down

0 comments on commit b35d8d3

Please sign in to comment.