about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-04-06T12·30+0200
committerEelco Dolstra <edolstra@gmail.com>2017-04-06T12·30+0200
commit256940fc48a6db950136fb0bc43590b701a3e857 (patch)
tree33ce2b1e13f0aba27d4046c5fa2364a758583520 /src/libstore
parent8decb07c31581febab664bedde12c8bf1367279e (diff)
nix-daemon: Disable path info cache
This is useless because the client also caches path info, and can
cause problems for long-running clients like hydra-queue-runner
(i.e. it may return cached info about paths that have been
garbage-collected).
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/store-api.cc1
-rw-r--r--src/libstore/store-api.hh7
2 files changed, 7 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 441166d04d8f..59348c5d0b5f 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -242,6 +242,7 @@ Path Store::computeStorePathForText(const string & name, const string & s,
 
 Store::Store(const Params & params)
     : storeDir(get(params, "store", settings.nixStore))
+    , state({std::stoi(get(params, "path-info-cache-size", "65536"))})
 {
 }
 
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 98f2803f8136..f58dbde350c7 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -241,7 +241,7 @@ protected:
 
     struct State
     {
-        LRUCache<std::string, std::shared_ptr<ValidPathInfo>> pathInfoCache{64 * 1024};
+        LRUCache<std::string, std::shared_ptr<ValidPathInfo>> pathInfoCache;
     };
 
     Sync<State> state;
@@ -252,6 +252,11 @@ protected:
 
 public:
 
+    size_t getCacheSize()
+    {
+        return state.lock()->pathInfoCache.size();
+    }
+
     virtual ~Store() { }
 
     virtual std::string getUri() = 0;