Skip to content

Commit 31b6aa7

Browse files
committed
fix: fix build cache key
1 parent b3eae4a commit 31b6aa7

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packages/core/services/build/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition.workspace = true
99
acme-lib = "0.9"
1010
anyhow = "1.0"
1111
chirp-workflow.workspace = true
12+
cjson = "0.1"
1213
cloudflare.workspace = true
1314
heck = "0.3"
1415
http = "0.2"

packages/core/services/build/src/ops/resolve_for_tags.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,33 @@ pub struct Output {
1919

2020
#[operation]
2121
pub async fn build_resolve_for_tags(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
22-
let tags_str = serde_json::to_string(&input.tags)?;
22+
let tags_str = unwrap!(cjson::to_string(&input.tags));
2323

2424
let builds = if input.bypass_cache {
2525
get_builds(&ctx, input.env_id, &tags_str).await?
2626
} else {
2727
unwrap!(
2828
ctx.cache()
2929
.ttl(util::duration::seconds(15))
30-
.fetch_one_json("build", tags_str.as_str(), {
31-
let ctx = ctx.clone();
32-
let tags_str = tags_str.clone();
33-
move |mut cache, key| {
30+
.fetch_one_json(
31+
"build",
32+
format!("{}:{}", input.env_id, tags_str.as_str()),
33+
{
3434
let ctx = ctx.clone();
3535
let tags_str = tags_str.clone();
36-
async move {
37-
let builds = get_builds(&ctx, input.env_id, &tags_str).await?;
36+
move |mut cache, key| {
37+
let ctx = ctx.clone();
38+
let tags_str = tags_str.clone();
39+
async move {
40+
let builds = get_builds(&ctx, input.env_id, &tags_str).await?;
3841

39-
cache.resolve(&key, builds);
42+
cache.resolve(&key, builds);
4043

41-
Ok(cache)
44+
Ok(cache)
45+
}
4246
}
4347
}
44-
})
48+
)
4549
.await?
4650
)
4751
};

0 commit comments

Comments
 (0)