From fe32cf6901c6733dce52c898b57c12a9c355e187 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Thu, 15 Aug 2024 08:15:25 -0400 Subject: [PATCH] Change `--zarrman-cache-bytes` to `--zarrman-cache-mb` --- CHANGELOG.md | 2 +- README.md | 6 +++--- src/consts.rs | 4 ---- src/main.rs | 10 +++++----- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a888c4..fcc2a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ In Development - Format all log lines as JSON - Add logging of Zarr manifest cache events - Limit Zarr manifest cache by total size of entries - - Add a `-Z`/`--zarrman-cache-bytes` option for setting the cache size + - Add a `-Z`/`--zarrman-cache-mb` option for setting the cache size - Expire idle Zarr manifest cache entries - Log Zarr manifest cache entries every hour diff --git a/README.md b/README.md index 70c34c4..dfeb852 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,6 @@ Options views of collections (used inside ``'s and as the root breadcrumb text) [default: dandidav] -- `-Z <INT>`, `--zarrman-cache-bytes <INT>` — Specify the maximum number of - bytes of parsed Zarr manifest files to store in the Zarr manifest cache at - once [default: 100 MiB] +- `-Z <INT>`, `--zarrman-cache-mb <INT>` — Specify the maximum number of + megabytes (1,000,000 bytes) of parsed Zarr manifest files to store in the + Zarr manifest cache at once [default: 100] diff --git a/src/consts.rs b/src/consts.rs index 96fcb39..65761df 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -61,10 +61,6 @@ pub(crate) static FAST_NOT_EXIST: &[&str] = &[".bzr", ".git", ".nols", ".svn"]; /// Interval between periodic logging of the Zarr manifest cache's contents pub(crate) const ZARR_MANIFEST_CACHE_DUMP_PERIOD: Duration = Duration::from_secs(3600); -/// Default size of the Zarr manifest cache; the cache is limited to storing no -/// more than this many bytes of parsed manifests at once -pub(crate) const ZARR_MANIFEST_CACHE_TOTAL_BYTES: u64 = 100 * 1024 * 1024; // 100 MiB - #[cfg(test)] mod tests { use super::*; diff --git a/src/main.rs b/src/main.rs index 21930db..f78d257 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,10 +66,10 @@ struct Arguments { #[arg(short = 'T', long, default_value = env!("CARGO_PKG_NAME"))] title: String, - /// Limit the Zarr manifest cache to storing no more than this many bytes - /// of parsed manifests at once - #[arg(short = 'Z', long, default_value_t = ZARR_MANIFEST_CACHE_TOTAL_BYTES, value_name = "INT")] - zarrman_cache_bytes: u64, + /// Limit the Zarr manifest cache to storing no more than this many + /// megabytes of parsed manifests at once + #[arg(short = 'Z', long, default_value_t = 100, value_name = "INT")] + zarrman_cache_mb: u64, } // See @@ -102,7 +102,7 @@ fn main() -> anyhow::Result<()> { async fn run() -> anyhow::Result<()> { let args = Arguments::parse(); let dandi = DandiClient::new(args.api_url)?; - let zarrfetcher = ManifestFetcher::new(args.zarrman_cache_bytes)?; + let zarrfetcher = ManifestFetcher::new(args.zarrman_cache_mb * 1_000_000)?; zarrfetcher.install_periodic_dump(ZARR_MANIFEST_CACHE_DUMP_PERIOD); let zarrman = ZarrManClient::new(zarrfetcher); let templater = Templater::new(args.title)?;