From 3c3dc7ee2f207c3c2fbe712bc6a493167094df7c Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Mon, 2 Sep 2024 20:41:50 -0700 Subject: Merge extensions between old and new meta on revalidate --- .bleep | 2 +- pingora-cache/src/lib.rs | 7 ++++++- pingora-cache/src/meta.rs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.bleep b/.bleep index a931ea7..e659893 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -089f8397486e934dbbe045085ba3648e0bb945a5 \ No newline at end of file +08724db8653366f6eee60a3236ed9c2987402fc0 \ No newline at end of file diff --git a/pingora-cache/src/lib.rs b/pingora-cache/src/lib.rs index 8f88299..1a97041 100644 --- a/pingora-cache/src/lib.rs +++ b/pingora-cache/src/lib.rs @@ -719,10 +719,15 @@ impl HttpCache { // that requires cacheable_filter to take a mut header and just return InternalMeta // update new meta with old meta's created time - let created = inner.meta.as_ref().unwrap().0.internal.created; + let old_meta = inner.meta.take().unwrap(); + let created = old_meta.0.internal.created; meta.0.internal.created = created; // meta.internal.updated was already set to new meta's `created`, // no need to set `updated` here + // Merge old extensions with new ones. New exts take precedence if they conflict. + let mut extensions = old_meta.0.extensions; + extensions.extend(meta.0.extensions); + meta.0.extensions = extensions; inner.meta.replace(meta); diff --git a/pingora-cache/src/meta.rs b/pingora-cache/src/meta.rs index 8ed034e..fd608d4 100644 --- a/pingora-cache/src/meta.rs +++ b/pingora-cache/src/meta.rs @@ -14,7 +14,7 @@ //! Metadata for caching -use http::Extensions; +pub use http::Extensions; use pingora_error::{Error, ErrorType::*, OrErr, Result}; use pingora_http::{HMap, ResponseHeader}; use serde::{Deserialize, Serialize}; -- cgit v1.2.3