You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to the nar-info disk cache (and using the same db).
This makes rebuilds muuch faster.
- This works regardless of the ca-derivations experimental feature.
I could modify the logic to not touch the db if the flag isn’t there,
but given that this is a trash-able local cache, it doesn’t seem to be
really worth it.
- We could unify the `NARs` and `Realisation` tables to only have one
generic kv table. This is left as an exercise to the reader.
- I didn’t update the cache db version number as the new schema just
adds a new table to the previous one, so the db will be transparently
migrated and is backwards-compatible.
Fix#4746
@@ -98,6 +111,26 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache
98
111
state->queryNAR.create(state->db,
99
112
"select present, namePart, url, compression, fileHash, fileSize, narHash, narSize, refs, deriver, sigs, ca from NARs where cache = ? and hashPart = ? and ((present = 0 and timestamp > ?) or (present = 1 and timestamp > ?))");
100
113
114
+
state->insertRealisation.create(state->db,
115
+
R"(
116
+
insert or replace into Realisations(cache, outputId, content, timestamp, present)
117
+
values (?, ?, ?, ?, 1)
118
+
)");
119
+
120
+
state->insertMissingRealisation.create(state->db,
121
+
R"(
122
+
insert or replace into Realisations(cache, outputId, timestamp, present)
123
+
values (?, ?, ?, 0)
124
+
)");
125
+
126
+
state->queryRealisation.create(state->db,
127
+
R"(
128
+
select present, content from Realisations
129
+
where cache = ? and outputId = ? and
130
+
((present = 0 and timestamp > ?) or
131
+
(present = 1 and timestamp > ?))
132
+
)");
133
+
101
134
/* Periodically purge expired entries from the database. */
102
135
retrySQLite<void>([&]() {
103
136
auto now = time(0);
@@ -212,6 +245,38 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache
0 commit comments