1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 07:33:16 +02:00

pathInfoCache: Respect disk cache TTLs #3398

This commit is contained in:
Robert Hensing 2020-03-11 20:04:47 +01:00
parent 9080d5d924
commit 3f55f8a8fb
4 changed files with 39 additions and 11 deletions

View file

@ -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;