about summary refs log tree commit diff
path: root/src/libstore/nar-info-disk-cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/nar-info-disk-cache.cc')
-rw-r--r--src/libstore/nar-info-disk-cache.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index b05f2661ea8d..0751dda19286 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -57,6 +57,8 @@ public:
     {
         int id;
         Path storeDir;
+        bool wantMassQuery;
+        int priority;
     };
 
     struct State
@@ -126,24 +128,28 @@ public:
 
         state->insertCache.use()(uri)(time(0))(storeDir)(wantMassQuery)(priority).exec();
         assert(sqlite3_changes(state->db) == 1);
-        state->caches[uri] = Cache{(int) sqlite3_last_insert_rowid(state->db), storeDir};
+        state->caches[uri] = Cache{(int) sqlite3_last_insert_rowid(state->db), storeDir, wantMassQuery, priority};
     }
 
-    bool cacheExists(const std::string & uri) override
+    bool cacheExists(const std::string & uri,
+        bool & wantMassQuery, int & priority) override
     {
         auto state(_state.lock());
 
         auto i = state->caches.find(uri);
-        if (i != state->caches.end()) return true;
+        if (i == state->caches.end()) {
+            auto queryCache(state->queryCache.use()(uri));
+            if (!queryCache.next()) return false;
+            state->caches.emplace(uri,
+                Cache{(int) queryCache.getInt(0), queryCache.getStr(1), queryCache.getInt(2), (int) queryCache.getInt(3)});
+        }
 
-        auto queryCache(state->queryCache.use()(uri));
+        auto & cache(getCache(*state, uri));
 
-        if (queryCache.next()) {
-            state->caches[uri] = Cache{(int) queryCache.getInt(0), queryCache.getStr(1)};
-            return true;
-        }
+        wantMassQuery = cache.wantMassQuery;
+        priority = cache.priority;
 
-        return false;
+        return true;
     }
 
     std::pair<Outcome, std::shared_ptr<NarInfo>> lookupNarInfo(