2016-04-20 12:12:38 +00:00
|
|
|
#pragma once
|
2023-04-01 03:18:41 +00:00
|
|
|
///@file
|
2016-04-20 12:12:38 +00:00
|
|
|
|
|
|
|
#include "ref.hh"
|
|
|
|
#include "nar-info.hh"
|
2021-05-06 14:45:09 +00:00
|
|
|
#include "realisation.hh"
|
2016-04-20 12:12:38 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class NarInfoDiskCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef enum { oValid, oInvalid, oUnknown } Outcome;
|
|
|
|
|
2020-03-24 13:26:13 +00:00
|
|
|
virtual ~NarInfoDiskCache() { }
|
2019-11-26 20:07:44 +00:00
|
|
|
|
2023-01-17 18:56:06 +00:00
|
|
|
virtual int createCache(const std::string & uri, const Path & storeDir,
|
2016-06-01 12:49:12 +00:00
|
|
|
bool wantMassQuery, int priority) = 0;
|
2016-04-20 12:12:38 +00:00
|
|
|
|
2019-12-17 16:17:53 +00:00
|
|
|
struct CacheInfo
|
|
|
|
{
|
2023-01-30 21:15:23 +00:00
|
|
|
int id;
|
2019-12-17 16:17:53 +00:00
|
|
|
bool wantMassQuery;
|
|
|
|
int priority;
|
|
|
|
};
|
|
|
|
|
2023-01-17 18:54:47 +00:00
|
|
|
virtual std::optional<CacheInfo> upToDateCacheExists(const std::string & uri) = 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;
|
2021-05-06 14:45:09 +00:00
|
|
|
|
|
|
|
virtual void upsertRealisation(
|
|
|
|
const std::string & uri,
|
|
|
|
const Realisation & realisation) = 0;
|
|
|
|
virtual void upsertAbsentRealisation(
|
|
|
|
const std::string & uri,
|
|
|
|
const DrvOutput & id) = 0;
|
|
|
|
virtual std::pair<Outcome, std::shared_ptr<Realisation>> lookupRealisation(
|
|
|
|
const std::string & uri, const DrvOutput & id) = 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();
|
|
|
|
|
2023-01-30 21:15:23 +00:00
|
|
|
ref<NarInfoDiskCache> getTestNarInfoDiskCache(Path dbPath);
|
|
|
|
|
2016-04-20 12:12:38 +00:00
|
|
|
}
|