]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/shared_lru: introduce cached_key_lower_bound()
authorMatan Breizman <mbreizma@redhat.com>
Thu, 9 Nov 2023 16:51:20 +0000 (16:51 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 29 Nov 2023 08:32:00 +0000 (08:32 +0000)
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/common/shared_lru.h

index 186f02a614c9bfcc4b38614082fa1c81f00e7ee2..92d99d332c44ddc013da33fb98801c95be793fe1 100644 (file)
@@ -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<K,V>::find(const K& key)
   return val;
 }
 
+template<class K, class V>
+K SharedLRU<K,V>::cached_key_lower_bound()
+{
+  if (weak_refs.empty()) {
+    return {};
+  }
+  return weak_refs.begin()->first;
+}
+
 template<class K, class V>
 typename SharedLRU<K,V>::shared_ptr_t
 SharedLRU<K,V>::lower_bound(const K& key)