aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-api.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r--src/libstore/store-api.hh21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index a000757fb..e0484de13 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -16,6 +16,7 @@
#include <unordered_set>
#include <memory>
#include <string>
+#include <chrono>
namespace nix {
@@ -261,10 +262,28 @@ public:
protected:
+ struct PathInfoCacheValue {
+
+ // Time of cache entry creation or update
+ std::chrono::time_point<std::chrono::steady_clock> time_point = std::chrono::steady_clock::now();
+
+ // Null if missing
+ std::shared_ptr<const ValidPathInfo> value;
+
+ // Whether the value is valid as a cache entry. The path may not exist.
+ bool isKnownNow();
+
+ // Past tense, because a path can only be assumed to exists when
+ // isKnownNow() && didExist()
+ inline bool didExist() {
+ return value != nullptr;
+ }
+ };
+
struct State
{
// FIXME: fix key
- LRUCache<std::string, std::shared_ptr<const ValidPathInfo>> pathInfoCache;
+ LRUCache<std::string, PathInfoCacheValue> pathInfoCache;
};
Sync<State> state;