chore: Upgrade cached and use new sync_writes by_key for faster operations

This commit is contained in:
Gerald Pinder 2025-04-07 11:59:04 -04:00
parent a62b6ff43c
commit ad53cdcb8c
8 changed files with 47 additions and 12 deletions

40
Cargo.lock generated
View file

@ -439,7 +439,7 @@ dependencies = [
"blue-build-template",
"blue-build-utils",
"bon",
"cached",
"cached 0.55.1",
"clap",
"clap-verbosity-flag",
"clap_complete",
@ -482,7 +482,7 @@ dependencies = [
"anyhow",
"blue-build-utils",
"bon",
"cached",
"cached 0.55.1",
"chrono",
"clap",
"colored",
@ -552,7 +552,7 @@ dependencies = [
"base64 0.22.1",
"blake2",
"bon",
"cached",
"cached 0.55.1",
"chrono",
"clap",
"comlexr",
@ -647,7 +647,7 @@ checksum = "9718806c4a2fe9e8a56fd736f97b340dd10ed1be8ed733ed50449f351dc33cae"
dependencies = [
"ahash 0.8.11",
"async-trait",
"cached_proc_macro",
"cached_proc_macro 0.23.0",
"cached_proc_macro_types",
"futures",
"hashbrown 0.14.5",
@ -657,6 +657,24 @@ dependencies = [
"web-time",
]
[[package]]
name = "cached"
version = "0.55.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0839c297f8783316fcca9d90344424e968395413f0662a5481f79c6648bbc14"
dependencies = [
"ahash 0.8.11",
"async-trait",
"cached_proc_macro 0.24.0",
"cached_proc_macro_types",
"futures",
"hashbrown 0.14.5",
"once_cell",
"thiserror 2.0.12",
"tokio",
"web-time",
]
[[package]]
name = "cached_proc_macro"
version = "0.23.0"
@ -669,6 +687,18 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "cached_proc_macro"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673992d934f0711b68ebb3e1b79cdc4be31634b37c98f26867ced0438ca5c603"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "cached_proc_macro_types"
version = "0.1.1"
@ -4431,7 +4461,7 @@ checksum = "9958ac57dea620d4059784dc0df9f997a873a168828d1028c5c7b9d7a089f5f2"
dependencies = [
"async-trait",
"base64 0.22.1",
"cached",
"cached 0.54.0",
"cfg-if",
"chrono",
"const-oid",

View file

@ -11,7 +11,7 @@ version = "0.9.10"
[workspace.dependencies]
bon = "3"
cached = "0.54"
cached = "0.55"
chrono = "0.4"
clap = "4"
colored = "2"

View file

@ -254,7 +254,7 @@ impl Driver {
result = true,
key = "String",
convert = r#"{ oci_ref.to_string() }"#,
sync_writes = true
sync_writes = "by_key"
)]
fn get_version_run_image(oci_ref: &Reference) -> Result<u64> {
warn!(concat!(

View file

@ -432,7 +432,7 @@ impl InspectDriver for DockerDriver {
result = true,
key = "String",
convert = r#"{ format!("{}-{}", opts.image, opts.platform)}"#,
sync_writes = true
sync_writes = "by_key"
)]
fn get_metadata_cache(opts: &GetMetadataOpts) -> Result<ImageMetadata> {
trace!("DockerDriver::get_metadata({opts:#?})");

View file

@ -326,7 +326,7 @@ impl InspectDriver for PodmanDriver {
result = true,
key = "String",
convert = r#"{ format!("{}-{}", opts.image, opts.platform)}"#,
sync_writes = true
sync_writes = "by_key"
)]
fn get_metadata_cache(opts: &GetMetadataOpts) -> Result<ImageMetadata> {
trace!("PodmanDriver::get_metadata({opts:#?})");

View file

@ -24,7 +24,7 @@ impl InspectDriver for SkopeoDriver {
result = true,
key = "String",
convert = r#"{ format!("{}-{}", opts.image, opts.platform)}"#,
sync_writes = true
sync_writes = "by_key"
)]
fn get_metadata_cache(opts: &GetMetadataOpts) -> Result<ImageMetadata> {
trace!("SkopeoDriver::get_metadata({opts:#?})");

View file

@ -181,7 +181,7 @@ impl GenerateCommand {
result = true,
key = "Platform",
convert = r#"{ platform }"#,
sync_writes = true
sync_writes = "by_key"
)]
fn determine_scripts_tag(platform: Platform) -> Result<Reference> {
trace!("determine_scripts_tag({platform:?})");

View file

@ -313,7 +313,12 @@ impl Retrieve for ModuleSchemaRetriever {
}
}
#[cached(result = true, key = "String", convert = r#"{ format!("{uri}") }"#)]
#[cached(
result = true,
key = "String",
convert = r#"{ format!("{uri}") }"#,
sync_writes = "by_key"
)]
async fn cache_retrieve(uri: &Uri<String>) -> miette::Result<Value> {
let scheme = uri.scheme();
let path = uri.path();