Add caching for crates.io metadata#2
Merged
Merged
Conversation
There was a problem hiding this comment.
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.rsmodule providingResponseCachewith TTL-bounded all-versions caching, indefinite publish-date caching, atomic save via tmp+rename, and tests. CratesIoClientis now stateful (&mut self), consults/populates the cache, and exposesrate_limit()(skipping the 100 ms sleep on cache hits) andsave_cache().- CLI gains
--cache-path(withCARGO_OXIDATE_CACHE_PATHenv) and--cache-max-age-hours; the composite action adds acache-responsesinput that provisionsactions/cachekeyed onCargo.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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cache crates.io metadata so we don't have to fetch it every time.