summaryrefslogtreecommitdiff
path: root/src/mongo/util/read_through_cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/read_through_cache.h')
-rw-r--r--src/mongo/util/read_through_cache.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mongo/util/read_through_cache.h b/src/mongo/util/read_through_cache.h
index 3d5c7bf0923..72b3e7a5771 100644
--- a/src/mongo/util/read_through_cache.h
+++ b/src/mongo/util/read_through_cache.h
@@ -136,10 +136,12 @@ public:
*/
class ValueHandle {
public:
- // The two constructors below are present in order to offset the fact that the cache doesn't
- // support pinning items. Their only usage must be in the authorization mananager for the
- // internal authentication user.
+ // The three constructors below are present in order to offset the fact that the cache
+ // doesn't support pinning items. Their only usage must be in the authorization mananager
+ // for the internal authentication user.
ValueHandle(Value&& value) : _valueHandle({std::move(value), Date_t::min()}) {}
+ ValueHandle(Value&& value, const Time& t)
+ : _valueHandle({std::move(value), Date_t::min()}, t) {}
ValueHandle() = default;
operator bool() const {
@@ -289,6 +291,16 @@ public:
}
/**
+ * Acquires the latest value from the cache, or an empty ValueHandle if the key is not present
+ * in the cache.
+ *
+ * Doesn't attempt to lookup, and so doesn't block.
+ */
+ ValueHandle peekLatestCached(const Key& key) {
+ return {_cache.get(key, CacheCausalConsistency::kLatestCached)};
+ }
+
+ /**
* Invalidates the given 'key' and immediately replaces it with a new value.
*/
ValueHandle insertOrAssignAndGet(const Key& key, Value&& newValue, Date_t updateWallClockTime) {