From d2c5c04f36d040d69df0f76679be9802eee95c8e Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Thu, 9 Nov 2023 16:51:20 +0000 Subject: [PATCH] crimson/common/shared_lru: introduce cached_key_lower_bound() Signed-off-by: Matan Breizman --- src/crimson/common/shared_lru.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/crimson/common/shared_lru.h b/src/crimson/common/shared_lru.h index 186f02a614c..92d99d332c4 100644 --- a/src/crimson/common/shared_lru.h +++ b/src/crimson/common/shared_lru.h @@ -83,6 +83,7 @@ public: cache.clear(); } shared_ptr_t find(const K& key); + K cached_key_lower_bound(); // return the last element that is not greater than key shared_ptr_t lower_bound(const K& key); // return the first element that is greater than key @@ -146,6 +147,15 @@ SharedLRU::find(const K& key) return val; } +template +K SharedLRU::cached_key_lower_bound() +{ + if (weak_refs.empty()) { + return {}; + } + return weak_refs.begin()->first; +} + template typename SharedLRU::shared_ptr_t SharedLRU::lower_bound(const K& key) -- 2.39.5