2016-04-20 12:12:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ref.hh"
|
|
|
|
#include "nar-info.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class NarInfoDiskCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef enum { oValid, oInvalid, oUnknown } Outcome;
|
|
|
|
|
2016-06-01 12:49:12 +00:00
|
|
|
virtual void createCache(const std::string & uri, const Path & storeDir,
|
|
|
|
bool wantMassQuery, int priority) = 0;
|
2016-04-20 12:12:38 +00:00
|
|
|
|
2016-06-01 13:15:21 +00:00
|
|
|
virtual bool cacheExists(const std::string & uri,
|
|
|
|
bool & wantMassQuery, int & priority) = 0;
|
2016-04-20 12:12:38 +00:00
|
|
|
|
|
|
|
virtual std::pair<Outcome, std::shared_ptr<NarInfo>> lookupNarInfo(
|
2016-04-21 15:53:47 +00:00
|
|
|
const std::string & uri, const std::string & hashPart) = 0;
|
2016-04-20 12:12:38 +00:00
|
|
|
|
|
|
|
virtual void upsertNarInfo(
|
2016-04-21 15:53:47 +00:00
|
|
|
const std::string & uri, const std::string & hashPart,
|
2018-09-25 16:54:16 +00:00
|
|
|
std::shared_ptr<const ValidPathInfo> info) = 0;
|
2016-04-20 12:12:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Return a singleton cache object that can be used concurrently by
|
|
|
|
multiple threads. */
|
|
|
|
ref<NarInfoDiskCache> getNarInfoDiskCache();
|
|
|
|
|
|
|
|
}
|