diff options
author | Eli Kogan-Wang <elikowa@gmail.com> | 2022-05-16 02:28:21 +0200 |
---|---|---|
committer | Eli Kogan-Wang <elikowa@gmail.com> | 2022-05-16 02:29:29 +0200 |
commit | c81d24f1c70cc454c9a88cea70048d8563f60784 (patch) | |
tree | 1a12c792e2725da29b0377b00b3ae3fd21642361 /src/libexpr/eval-cache.cc | |
parent | 0cea59ab4bbd7902d61dd02df8136fae3ae8d4c9 (diff) |
Add int to eval-cache, bump eval cache schema version
Diffstat (limited to 'src/libexpr/eval-cache.cc')
-rw-r--r-- | src/libexpr/eval-cache.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc index b4bce512b..bf811c8ed 100644 --- a/src/libexpr/eval-cache.cc +++ b/src/libexpr/eval-cache.cc @@ -47,7 +47,7 @@ struct AttrDb { auto state(_state->lock()); - Path cacheDir = getCacheDir() + "/nix/eval-cache-v3"; + Path cacheDir = getCacheDir() + "/nix/eval-cache-v4"; createDirs(cacheDir); Path dbPath = cacheDir + "/" + fingerprint.to_string(Base16, false) + ".sqlite"; @@ -175,6 +175,24 @@ struct AttrDb }); } + AttrId setInt( + AttrKey key, + int n) + { + return doSQLite([&]() + { + auto state(_state->lock()); + + state->insertAttribute.use() + (key.first) + (symbols[key.second]) + (AttrType::Int) + (n).exec(); + + return state->db.getLastInsertedRowId(); + }); + } + AttrId setListOfStrings( AttrKey key, const std::vector<std::string> & l) @@ -287,6 +305,8 @@ struct AttrDb } case AttrType::Bool: return {{rowId, queryAttribute.getInt(2) != 0}}; + case AttrType::Int: + return {{rowId, queryAttribute.getInt(2)}}; case AttrType::ListOfStrings: return {{rowId, tokenizeString<std::vector<std::string>>(queryAttribute.getStr(2), "\t")}}; case AttrType::Missing: @@ -426,6 +446,8 @@ Value & AttrCursor::forceValue() cachedValue = {root->db->setString(getKey(), v.path), string_t{v.path, {}}}; else if (v.type() == nBool) cachedValue = {root->db->setBool(getKey(), v.boolean), v.boolean}; + else if (v.type() == nInt) + cachedValue = {root->db->setInt(getKey(), v.integer), v.integer}; else if (v.type() == nAttrs) ; // FIXME: do something? else |