From 9850e92e33af870a0761c2473673f9a0ada61b0b Mon Sep 17 00:00:00 2001 From: Kevin Guthrie Date: Mon, 18 Nov 2024 10:43:52 -0500 Subject: Add the ability to trigger forced-miss behavior from the `cache_hit_filter` function --- pingora-proxy/src/proxy_trait.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'pingora-proxy/src/proxy_trait.rs') diff --git a/pingora-proxy/src/proxy_trait.rs b/pingora-proxy/src/proxy_trait.rs index 6970ec0..00e54f4 100644 --- a/pingora-proxy/src/proxy_trait.rs +++ b/pingora-proxy/src/proxy_trait.rs @@ -13,7 +13,11 @@ // limitations under the License. use super::*; -use pingora_cache::{key::HashBinary, CacheKey, CacheMeta, RespCacheable, RespCacheable::*}; +use pingora_cache::{ + key::HashBinary, + CacheKey, CacheMeta, ForcedInvalidationKind, + RespCacheable::{self, *}, +}; use std::time::Duration; /// The interface to control the HTTP proxy @@ -129,21 +133,23 @@ pub trait ProxyHttp { session.cache.cache_miss(); } - /// This filter is called after a successful cache lookup and before the cache asset is ready to - /// be used. + /// This filter is called after a successful cache lookup and before the + /// cache asset is ready to be used. /// - /// This filter allow the user to log or force expire the asset. - // flex purge, other filtering, returns whether asset is should be force expired or not + /// This filter allows the user to log or force invalidate the asset. + /// + /// The value returned indicates if the force invalidation should be used, + /// and which kind. Returning `None` indicates no forced invalidation async fn cache_hit_filter( &self, _session: &Session, _meta: &CacheMeta, _ctx: &mut Self::CTX, - ) -> Result + ) -> Result> where Self::CTX: Send + Sync, { - Ok(false) + Ok(None) } /// Decide if a request should continue to upstream after not being served from cache. -- cgit v1.2.3