summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2020-07-27 16:21:40 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-27 06:39:40 +0000
commit21a3ee6079eb3cc83a5210cf53d98840cbc83a20 (patch)
tree9c945f3dc2eecc83ecdfd5627a183e6f50838565
parenta227368b53731b37ef0e95ae4d2e55fa6dbcf517 (diff)
downloadmongo-21a3ee6079eb3cc83a5210cf53d98840cbc83a20.tar.gz
SERVER-49189 add missed minor tweaks
-rw-r--r--src/mongo/util/invalidating_lru_cache.h2
-rw-r--r--src/mongo/util/invalidating_lru_cache_test.cpp8
-rw-r--r--src/mongo/util/read_through_cache.h15
3 files changed, 12 insertions, 13 deletions
diff --git a/src/mongo/util/invalidating_lru_cache.h b/src/mongo/util/invalidating_lru_cache.h
index a647a14de89..18b9a94c9fa 100644
--- a/src/mongo/util/invalidating_lru_cache.h
+++ b/src/mongo/util/invalidating_lru_cache.h
@@ -408,7 +408,7 @@ public:
* which can either be from the time of insertion or from the latest call to
* 'advanceTimeInStore'. Otherwise, returns a nullptr ValueHandle and Time().
*/
- std::pair<ValueHandle, Time> getCachedValueAndTime(const Key& key) {
+ std::pair<ValueHandle, Time> getCachedValueAndTimeInStore(const Key& key) {
stdx::lock_guard<Latch> lg(_mutex);
std::shared_ptr<StoredValue> storedValue;
if (auto it = _cache.find(key); it != _cache.end()) {
diff --git a/src/mongo/util/invalidating_lru_cache_test.cpp b/src/mongo/util/invalidating_lru_cache_test.cpp
index 08fcc930486..282a130af68 100644
--- a/src/mongo/util/invalidating_lru_cache_test.cpp
+++ b/src/mongo/util/invalidating_lru_cache_test.cpp
@@ -269,7 +269,7 @@ TEST(InvalidatingLRUCacheTest, CausalConsistencyPreservedForEvictedCheckedOutKey
// list
cache.insertOrAssign(2, TestValue("Key 2 - Value @ TS 20"), Timestamp(20));
- auto [cachedValueAtTS10, timeInStoreAtTS10] = cache.getCachedValueAndTime(1);
+ auto [cachedValueAtTS10, timeInStoreAtTS10] = cache.getCachedValueAndTimeInStore(1);
ASSERT_EQ(Timestamp(10), timeInStoreAtTS10);
ASSERT_EQ("Key 1 - Value @ TS 10", cachedValueAtTS10->value);
ASSERT_EQ("Key 1 - Value @ TS 10", key1ValueAtTS10->value);
@@ -277,7 +277,7 @@ TEST(InvalidatingLRUCacheTest, CausalConsistencyPreservedForEvictedCheckedOutKey
ASSERT_EQ("Key 1 - Value @ TS 10", cache.get(1, CacheCausalConsistency::kLatestKnown)->value);
cache.advanceTimeInStore(1, Timestamp(11));
- auto [cachedValueAtTS11, timeInStoreAtTS11] = cache.getCachedValueAndTime(1);
+ auto [cachedValueAtTS11, timeInStoreAtTS11] = cache.getCachedValueAndTimeInStore(1);
ASSERT_EQ(Timestamp(11), timeInStoreAtTS11);
ASSERT(!key1ValueAtTS10.isValid());
ASSERT_EQ("Key 1 - Value @ TS 10", cachedValueAtTS11->value);
@@ -431,7 +431,7 @@ TEST(InvalidatingLRUCacheTest, CacheSizeZeroCausalConsistency) {
cache.advanceTimeInStore(100, Timestamp(30));
cache.insertOrAssign(100, TestValue("Value @ TS 30"), Timestamp(30));
- auto [cachedValueAtTS30, timeInStoreAtTS30] = cache.getCachedValueAndTime(100);
+ auto [cachedValueAtTS30, timeInStoreAtTS30] = cache.getCachedValueAndTimeInStore(100);
ASSERT_EQ(Timestamp(), timeInStoreAtTS30);
ASSERT(!cachedValueAtTS30);
@@ -440,7 +440,7 @@ TEST(InvalidatingLRUCacheTest, CacheSizeZeroCausalConsistency) {
ASSERT_EQ("Value @ TS 30", cache.get(100, CacheCausalConsistency::kLatestKnown)->value);
cache.advanceTimeInStore(100, Timestamp(35));
- auto [cachedValueAtTS35, timeInStoreAtTS35] = cache.getCachedValueAndTime(100);
+ auto [cachedValueAtTS35, timeInStoreAtTS35] = cache.getCachedValueAndTimeInStore(100);
ASSERT_EQ(Timestamp(35), timeInStoreAtTS35);
ASSERT_EQ("Value @ TS 30", cachedValueAtTS35->value);
ASSERT_EQ("Value @ TS 30", cache.get(100, CacheCausalConsistency::kLatestCached)->value);
diff --git a/src/mongo/util/read_through_cache.h b/src/mongo/util/read_through_cache.h
index 159b106fcdd..656f5c04a42 100644
--- a/src/mongo/util/read_through_cache.h
+++ b/src/mongo/util/read_through_cache.h
@@ -98,14 +98,14 @@ protected:
};
template <typename Result, typename Key, typename Value, typename Time>
-struct ReadThroughCacheLookupFnImpl {
- using fn = unique_function<Result(
+struct ReadThroughCacheLookup {
+ using Fn = unique_function<Result(
OperationContext*, const Key&, const Value& cachedValue, const Time& timeInStore)>;
};
template <typename Result, typename Key, typename Value>
-struct ReadThroughCacheLookupFnImpl<Result, Key, Value, CacheNotCausallyConsistent> {
- using fn = unique_function<Result(OperationContext*, const Key&, const Value& cachedValue)>;
+struct ReadThroughCacheLookup<Result, Key, Value, CacheNotCausallyConsistent> {
+ using Fn = unique_function<Result(OperationContext*, const Key&, const Value& cachedValue)>;
};
/**
@@ -218,8 +218,7 @@ public:
Time t;
};
- using LookupFn =
- typename ReadThroughCacheLookupFnImpl<LookupResult, Key, ValueHandle, Time>::fn;
+ using LookupFn = typename ReadThroughCacheLookup<LookupResult, Key, ValueHandle, Time>::Fn;
// Exposed publicly so it can be unit-tested indepedently of the usages in this class. Must not
// be used independently.
@@ -260,11 +259,11 @@ public:
return it->second->addWaiter(ul);
// Schedule an asynchronous lookup for the key
- auto [cachedValue, timeInStore] = _cache.getCachedValueAndTime(key);
+ auto [cachedValue, timeInStore] = _cache.getCachedValueAndTimeInStore(key);
auto [it, emplaced] = _inProgressLookups.emplace(
key,
std::make_unique<InProgressLookup>(
- *this, key, ValueHandle(std::move(cachedValue)), timeInStore));
+ *this, key, ValueHandle(std::move(cachedValue)), std::move(timeInStore)));
invariant(emplaced);
auto& inProgressLookup = *it->second;
auto sharedFutureToReturn = inProgressLookup.addWaiter(ul);