From 6e83d51ab12249b07cac60ecfd79d20bca5f49b5 Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Tue, 18 Jun 2024 19:05:56 -0700 Subject: [PATCH] Add is_hit fn to RTCache CacheStatus --- .bleep | 2 +- pingora-memory-cache/src/lib.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.bleep b/.bleep index dc07897..df99f64 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -f87e46c90fe2f84c2ce90ac1def9f4400ae45f24 \ No newline at end of file +1fe0ed665dfcf6222a4d08f6120172be64d27eb9 \ No newline at end of file diff --git a/pingora-memory-cache/src/lib.rs b/pingora-memory-cache/src/lib.rs index 5e0254b..b6e78bd 100644 --- a/pingora-memory-cache/src/lib.rs +++ b/pingora-memory-cache/src/lib.rs @@ -45,6 +45,14 @@ impl CacheStatus { Self::LockHit => "lock_hit", } } + + /// Returns whether this status represents a cache hit. + pub fn is_hit(&self) -> bool { + match self { + CacheStatus::Hit | CacheStatus::LockHit => true, + CacheStatus::Miss | CacheStatus::Expired => false, + } + } } #[derive(Debug, Clone)]