diff options
Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r-- | src/libstore/store-api.hh | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 88cfa5b5a..81014763d 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 { @@ -262,10 +263,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; |