diff options
author | Kevin Guthrie <[email protected]> | 2024-11-18 10:43:52 -0500 |
---|---|---|
committer | Yuchen Wu <[email protected]> | 2024-12-13 17:27:40 -0800 |
commit | 9850e92e33af870a0761c2473673f9a0ada61b0b (patch) | |
tree | 9f663f0694653c2764e1dc1d0d7fce99b34fd65b /pingora-proxy/src/proxy_trait.rs | |
parent | a8a6e77eef2c0f4d2a45f00c5b0e316dd373f2f2 (diff) | |
download | pingora-9850e92e33af870a0761c2473673f9a0ada61b0b.tar.gz pingora-9850e92e33af870a0761c2473673f9a0ada61b0b.zip |
Add the ability to trigger forced-miss behavior from the `cache_hit_filter` function
Diffstat (limited to 'pingora-proxy/src/proxy_trait.rs')
-rw-r--r-- | pingora-proxy/src/proxy_trait.rs | 20 |
1 files changed, 13 insertions, 7 deletions
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<bool> + ) -> Result<Option<ForcedInvalidationKind>> where Self::CTX: Send + Sync, { - Ok(false) + Ok(None) } /// Decide if a request should continue to upstream after not being served from cache. |