diff --git a/src/cache/disk_cache.rs b/src/cache/disk_cache.rs index 1018abb..87985db 100644 --- a/src/cache/disk_cache.rs +++ b/src/cache/disk_cache.rs @@ -17,7 +17,7 @@ use tokio_stream::wrappers::ReceiverStream; use super::{BoxedImageStream, Cache, CacheError, CacheKey, CacheStream, ImageMetadata}; -pub struct LowMemCache { +pub struct DiskCache { disk_path: PathBuf, disk_cur_size: AtomicU64, db_update_channel_sender: Sender, @@ -28,7 +28,7 @@ enum DbMessage { Put(Arc, u32), } -impl LowMemCache { +impl DiskCache { /// Constructs a new low memory cache at the provided path and capaci ty. /// This internally spawns a task that will wait for filesystem /// notifications when a file has been written. @@ -137,7 +137,7 @@ async fn db_listener( } #[async_trait] -impl Cache for LowMemCache { +impl Cache for DiskCache { async fn get( &self, key: &CacheKey, diff --git a/src/cache/mem_cache.rs b/src/cache/mem_cache.rs index 0cda2b2..a5d2e9f 100644 --- a/src/cache/mem_cache.rs +++ b/src/cache/mem_cache.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; -use crate::cache::LowMemCache; +use crate::cache::DiskCache; use super::{BoxedImageStream, Cache, CacheKey, CacheStream, ImageMetadata, MemStream}; use async_trait::async_trait; @@ -13,6 +13,7 @@ use tokio::sync::mpsc::{channel, Sender}; use tokio::sync::Mutex; /// Memory accelerated disk cache. Uses an LRU in memory to speed up reads. +/// pub struct MemoryLruCache { inner: Arc>, cur_mem_size: AtomicU64, @@ -29,7 +30,7 @@ impl MemoryLruCache { ) -> Arc> { let (tx, mut rx) = channel(100); let new_self = Arc::new(Box::new(Self { - inner: LowMemCache::new(disk_max_size, disk_path).await, + inner: DiskCache::new(disk_max_size, disk_path).await, cur_mem_size: AtomicU64::new(0), mem_cache: Mutex::new(LruCache::unbounded()), master_sender: tx, diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 7fc5e09..43006c5 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -17,7 +17,7 @@ use tokio::io::BufReader; use tokio::sync::mpsc::Sender; use tokio_util::codec::{BytesCodec, FramedRead}; -pub use disk_cache::LowMemCache; +pub use disk_cache::DiskCache; pub use fs::UpstreamError; pub use mem_cache::MemoryLruCache; diff --git a/src/main.rs b/src/main.rs index 9e3954a..fad005e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use std::{num::ParseIntError, sync::atomic::Ordering}; use actix_web::rt::{spawn, time, System}; use actix_web::web::{self, Data}; use actix_web::{App, HttpServer}; -use cache::{Cache, LowMemCache}; +use cache::{Cache, DiskCache}; use clap::Clap; use config::CliArgs; use log::{debug, error, warn, LevelFilter}; @@ -126,7 +126,7 @@ async fn main() -> Result<(), std::io::Error> { }); let cache: Arc> = if low_mem_mode { - LowMemCache::new(disk_quota, cache_path.clone()).await + DiskCache::new(disk_quota, cache_path.clone()).await } else { MemoryLruCache::new(disk_quota, cache_path.clone(), memory_max_size).await };