Skip to content

Commit

Permalink
Add is_hit fn to RTCache CacheStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
drcaramelsyrup committed Jun 28, 2024
1 parent c0b23c6 commit 6e83d51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f87e46c90fe2f84c2ce90ac1def9f4400ae45f24
1fe0ed665dfcf6222a4d08f6120172be64d27eb9
8 changes: 8 additions & 0 deletions pingora-memory-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 6e83d51

Please sign in to comment.