Skip to content

Commit

Permalink
Change --zarrman-cache-bytes to --zarrman-cache-mb
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Aug 15, 2024
1 parent 377a376 commit fe32cf6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ Options
views of collections (used inside `<title>`'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]
4 changes: 0 additions & 4 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 72 in src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/main.rs#L71-L72

Added lines #L71 - L72 were not covered by tests
}

// See
Expand Down Expand Up @@ -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);

Check warning on line 107 in src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/main.rs#L105-L107

Added lines #L105 - L107 were not covered by tests
let templater = Templater::new(args.title)?;
Expand Down

0 comments on commit fe32cf6

Please sign in to comment.