Skip to content

Add caching for crates.io metadata#2

Merged
timweri merged 5 commits into
mainfrom
thanh/caching
May 27, 2026
Merged

Add caching for crates.io metadata#2
timweri merged 5 commits into
mainfrom
thanh/caching

Conversation

@timweri

@timweri timweri commented May 27, 2026

Copy link
Copy Markdown
Owner

Cache crates.io metadata so we don't have to fetch it every time.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a persistent JSON-backed cache for crates.io API responses so that publish dates and per-crate version listings can be reused between runs, and wires the cache through the CLI and the GitHub Action.

Changes:

  • New src/cache.rs module providing ResponseCache with TTL-bounded all-versions caching, indefinite publish-date caching, atomic save via tmp+rename, and tests.
  • CratesIoClient is now stateful (&mut self), consults/populates the cache, and exposes rate_limit() (skipping the 100 ms sleep on cache hits) and save_cache().
  • CLI gains --cache-path (with CARGO_OXIDATE_CACHE_PATH env) and --cache-max-age-hours; the composite action adds a cache-responses input that provisions actions/cache keyed on Cargo.lock.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cache.rs New persistent cache module with serialization, TTL, atomic save, and tests.
src/api.rs Threads cache + TTL + last_was_cache_hit through fetch methods; splits uncached helpers; adds save_cache/rate_limit.
src/main.rs Wires CLI cache options into CratesIoClient; replaces inline sleeps with client.rate_limit(); calls save_cache() at end.
Cargo.toml Adds clap env feature, serde_json runtime dep, tempfile dev-dep.
Cargo.lock Lockfile updates for the new deps and their transitives.
action.yml Adds cache-responses input, resolves cache path, uses actions/cache, passes CARGO_OXIDATE_CACHE_PATH.
README.md Documents new CLI flags, caching section, and cache-responses action input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cache.rs
Comment thread src/main.rs
Comment thread src/api.rs
@timweri timweri marked this pull request as ready for review May 27, 2026 17:21
@timweri timweri merged commit b57953d into main May 27, 2026
5 checks passed
@timweri timweri deleted the thanh/caching branch May 27, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants