aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/require.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-21 16:59:31 +0900
committernsfisis <nsfisis@gmail.com>2026-02-21 16:59:31 +0900
commit261c3996805bcdfb7ff271290f3e3557dd15cea7 (patch)
treecc701824713b792729bb29f40181698efc387104 /crates/mozart/src/commands/require.rs
parent3535037592f149477c915a8b66da974eb59586db (diff)
downloadphp-mozart-261c3996805bcdfb7ff271290f3e3557dd15cea7.tar.gz
php-mozart-261c3996805bcdfb7ff271290f3e3557dd15cea7.tar.zst
php-mozart-261c3996805bcdfb7ff271290f3e3557dd15cea7.zip
feat(cache): add filesystem-backed cache with TTL expiration and size-limited GC
Implement a cache module with CacheConfig and Cache structs supporting read/write (string and binary), atomic writes via temp+rename, TTL-based expiration, and size-limited garbage collection. Wire the repo cache into packagist.rs and resolver.rs for API response caching, and the files cache into downloader.rs for dist archive caching. Implement the clear-cache command with full clear and --gc modes. All existing call sites pass None for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/require.rs')
-rw-r--r--crates/mozart/src/commands/require.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/mozart/src/commands/require.rs b/crates/mozart/src/commands/require.rs
index 128e4a9..7709f86 100644
--- a/crates/mozart/src/commands/require.rs
+++ b/crates/mozart/src/commands/require.rs
@@ -276,7 +276,7 @@ fn interactive_search_packages(
))
);
- match packagist::fetch_package_versions(&package_name) {
+ match packagist::fetch_package_versions(&package_name, None) {
Ok(versions) => {
match version::find_best_candidate(&versions, preferred_stability) {
Some(best) => {
@@ -469,7 +469,7 @@ pub fn execute(args: &RequireArgs, cli: &super::Cli) -> anyhow::Result<()> {
))
);
- let versions = packagist::fetch_package_versions(&name)?;
+ let versions = packagist::fetch_package_versions(&name, None)?;
let best = version::find_best_candidate(&versions, preferred_stability)
.ok_or_else(|| {
anyhow::anyhow!(
@@ -596,6 +596,7 @@ pub fn execute(args: &RequireArgs, cli: &super::Cli) -> anyhow::Result<()> {
platform: PlatformConfig::new(),
ignore_platform_reqs: args.ignore_platform_reqs,
ignore_platform_req_list: args.ignore_platform_req.clone(),
+ repo_cache: None,
};
// Print header messages
@@ -673,6 +674,7 @@ pub fn execute(args: &RequireArgs, cli: &super::Cli) -> anyhow::Result<()> {
composer_json_content: composer_json_content.clone(),
composer_json: raw.clone(),
include_dev: dev_mode,
+ repo_cache: None,
})?;
// Compute and print change report
@@ -934,6 +936,7 @@ mod tests {
platform: PlatformConfig::new(),
ignore_platform_reqs: false,
ignore_platform_req_list: vec![],
+ repo_cache: None,
};
let resolved = resolver::resolve(&request).expect("Resolution should succeed");
@@ -945,6 +948,7 @@ mod tests {
composer_json_content: composer_json_content.to_string(),
composer_json,
include_dev: false,
+ repo_cache: None,
})
.expect("Lock file generation should succeed");
@@ -980,6 +984,7 @@ mod tests {
platform: PlatformConfig::new(),
ignore_platform_reqs: false,
ignore_platform_req_list: vec![],
+ repo_cache: None,
};
let resolved = resolver::resolve(&request).expect("Resolution should succeed");
@@ -988,6 +993,7 @@ mod tests {
composer_json_content: content.to_string(),
composer_json: raw,
include_dev: false,
+ repo_cache: None,
})
.expect("Lock file generation should succeed");