forked from lix-project/hydra
Updates for negative .narinfo caching
This commit is contained in:
parent
177bf25d64
commit
afb86638cd
|
@ -639,6 +639,7 @@ void State::dumpStatus(Connection & conn, bool log)
|
|||
auto & stats = store->getStats();
|
||||
nested.attr("narInfoRead", stats.narInfoRead);
|
||||
nested.attr("narInfoReadAverted", stats.narInfoReadAverted);
|
||||
nested.attr("narInfoMissing", stats.narInfoMissing);
|
||||
nested.attr("narInfoWrite", stats.narInfoWrite);
|
||||
nested.attr("narInfoCacheSize", stats.narInfoCacheSize);
|
||||
nested.attr("narRead", stats.narRead);
|
||||
|
|
|
@ -87,9 +87,8 @@ bool S3BinaryCacheStore::isValidPath(const Path & storePath)
|
|||
try {
|
||||
readNarInfo(storePath);
|
||||
return true;
|
||||
} catch (S3Error & e) {
|
||||
if (e.err == Aws::S3::S3Errors::NO_SUCH_KEY) return false;
|
||||
throw;
|
||||
} catch (InvalidPath & e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +141,7 @@ void S3BinaryCacheStore::upsertFile(const std::string & path, const std::string
|
|||
stats.putTimeMs += duration;
|
||||
}
|
||||
|
||||
std::string S3BinaryCacheStore::getFile(const std::string & path)
|
||||
std::shared_ptr<std::string> S3BinaryCacheStore::getFile(const std::string & path)
|
||||
{
|
||||
printMsg(lvlDebug, format("fetching ‘s3://%1%/%2%’...") % bucketName % path);
|
||||
|
||||
|
@ -157,24 +156,31 @@ std::string S3BinaryCacheStore::getFile(const std::string & path)
|
|||
|
||||
stats.get++;
|
||||
|
||||
auto now1 = std::chrono::steady_clock::now();
|
||||
try {
|
||||
|
||||
auto result = checkAws(format("AWS error fetching ‘%s’") % path,
|
||||
client->GetObject(request));
|
||||
auto now1 = std::chrono::steady_clock::now();
|
||||
|
||||
auto now2 = std::chrono::steady_clock::now();
|
||||
auto result = checkAws(format("AWS error fetching ‘%s’") % path,
|
||||
client->GetObject(request));
|
||||
|
||||
auto res = dynamic_cast<std::stringstream &>(result.GetBody()).str();
|
||||
auto now2 = std::chrono::steady_clock::now();
|
||||
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
|
||||
auto res = dynamic_cast<std::stringstream &>(result.GetBody()).str();
|
||||
|
||||
printMsg(lvlTalkative, format("downloaded ‘s3://%1%/%2%’ (%3% bytes) in %4% ms")
|
||||
% bucketName % path % res.size() % duration);
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
|
||||
|
||||
stats.getBytes += res.size();
|
||||
stats.getTimeMs += duration;
|
||||
printMsg(lvlTalkative, format("downloaded ‘s3://%1%/%2%’ (%3% bytes) in %4% ms")
|
||||
% bucketName % path % res.size() % duration);
|
||||
|
||||
return res;
|
||||
stats.getBytes += res.size();
|
||||
stats.getTimeMs += duration;
|
||||
|
||||
return std::make_shared<std::string>(res);
|
||||
|
||||
} catch (S3Error & e) {
|
||||
if (e.err == Aws::S3::S3Errors::NO_SUCH_KEY) return 0;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ protected:
|
|||
|
||||
void upsertFile(const std::string & path, const std::string & data) override;
|
||||
|
||||
std::string getFile(const std::string & path) override;
|
||||
std::shared_ptr<std::string> getFile(const std::string & path) override;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue