diff options
author | Edward Wang <[email protected]> | 2024-06-18 19:05:56 -0700 |
---|---|---|
committer | Edward Wang <[email protected]> | 2024-06-28 12:34:25 -0700 |
commit | 6e83d51ab12249b07cac60ecfd79d20bca5f49b5 (patch) | |
tree | 365e9f07a53bdf518c35c8f5838e2575f1d3eb93 | |
parent | c0b23c67361a8e6b844103127a4e11507f567033 (diff) | |
download | pingora-6e83d51ab12249b07cac60ecfd79d20bca5f49b5.tar.gz pingora-6e83d51ab12249b07cac60ecfd79d20bca5f49b5.zip |
Add is_hit fn to RTCache CacheStatus
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-memory-cache/src/lib.rs | 8 |
2 files changed, 9 insertions, 1 deletions
@@ -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)] |