Skip to content

Commit cf0224f

Browse files
iTroozsylvestre
authored andcommitted
rename LazyDiskCache to LazyLruDiskCache
I think this name makes more sense, given that this type holds a lazily initialized LRU cache
1 parent 9fd99c7 commit cf0224f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/cache/disk.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,52 @@ use crate::errors::*;
2727

2828
use super::{normalize_key, PreprocessorCacheModeConfig};
2929

30-
enum LazyDiskCache {
30+
enum LazyLruDiskCache {
3131
Uninit { root: OsString, max_size: u64 },
3232
Init(LruDiskCache),
3333
}
3434

35-
impl LazyDiskCache {
35+
impl LazyLruDiskCache {
3636
fn get_or_init(&mut self) -> Result<&mut LruDiskCache> {
3737
match self {
38-
LazyDiskCache::Uninit { root, max_size } => {
39-
*self = LazyDiskCache::Init(LruDiskCache::new(&root, *max_size)?);
38+
LazyLruDiskCache::Uninit { root, max_size } => {
39+
*self = LazyLruDiskCache::Init(LruDiskCache::new(&root, *max_size)?);
4040
self.get_or_init()
4141
}
42-
LazyDiskCache::Init(d) => Ok(d),
42+
LazyLruDiskCache::Init(d) => Ok(d),
4343
}
4444
}
4545

4646
fn get(&mut self) -> Option<&mut LruDiskCache> {
4747
match self {
48-
LazyDiskCache::Uninit { .. } => None,
49-
LazyDiskCache::Init(d) => Some(d),
48+
LazyLruDiskCache::Uninit { .. } => None,
49+
LazyLruDiskCache::Init(d) => Some(d),
5050
}
5151
}
5252

5353
fn capacity(&self) -> u64 {
5454
match self {
55-
LazyDiskCache::Uninit { max_size, .. } => *max_size,
56-
LazyDiskCache::Init(d) => d.capacity(),
55+
LazyLruDiskCache::Uninit { max_size, .. } => *max_size,
56+
LazyLruDiskCache::Init(d) => d.capacity(),
5757
}
5858
}
5959

6060
fn path(&self) -> &Path {
6161
match self {
62-
LazyDiskCache::Uninit { root, .. } => root.as_ref(),
63-
LazyDiskCache::Init(d) => d.path(),
62+
LazyLruDiskCache::Uninit { root, .. } => root.as_ref(),
63+
LazyLruDiskCache::Init(d) => d.path(),
6464
}
6565
}
6666
}
6767

6868
/// A cache that stores entries at local disk paths.
6969
pub struct DiskCache {
7070
/// `LruDiskCache` does all the real work here.
71-
lru: Arc<Mutex<LazyDiskCache>>,
71+
lru: Arc<Mutex<LazyLruDiskCache>>,
7272
/// Thread pool to execute disk I/O
7373
pool: tokio::runtime::Handle,
7474
preprocessor_cache_mode_config: PreprocessorCacheModeConfig,
75-
preprocessor_cache: Arc<Mutex<LazyDiskCache>>,
75+
preprocessor_cache: Arc<Mutex<LazyLruDiskCache>>,
7676
rw_mode: CacheMode,
7777
}
7878

@@ -86,13 +86,13 @@ impl DiskCache {
8686
rw_mode: CacheMode,
8787
) -> DiskCache {
8888
DiskCache {
89-
lru: Arc::new(Mutex::new(LazyDiskCache::Uninit {
89+
lru: Arc::new(Mutex::new(LazyLruDiskCache::Uninit {
9090
root: root.as_ref().to_os_string(),
9191
max_size,
9292
})),
9393
pool: pool.clone(),
9494
preprocessor_cache_mode_config,
95-
preprocessor_cache: Arc::new(Mutex::new(LazyDiskCache::Uninit {
95+
preprocessor_cache: Arc::new(Mutex::new(LazyLruDiskCache::Uninit {
9696
root: Path::new(root.as_ref())
9797
.join("preprocessor")
9898
.into_os_string(),

0 commit comments

Comments
 (0)