2016-04-20 15:12:38 +03:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2016-04-20 15:12:38 +03:00
|
|
|
|
|
|
|
#include "ref.hh"
|
|
|
|
#include "nar-info.hh"
|
2021-05-06 17:45:09 +03:00
|
|
|
#include "realisation.hh"
|
2016-04-20 15:12:38 +03:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class NarInfoDiskCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef enum { oValid, oInvalid, oUnknown } Outcome;
|
|
|
|
|
2020-03-24 15:26:13 +02:00
|
|
|
virtual ~NarInfoDiskCache() { }
|
2019-11-26 22:07:44 +02:00
|
|
|
|
2023-01-17 20:56:06 +02:00
|
|
|
virtual int createCache(const std::string & uri, const Path & storeDir,
|
2016-06-01 15:49:12 +03:00
|
|
|
bool wantMassQuery, int priority) = 0;
|
2016-04-20 15:12:38 +03:00
|
|
|
|
2019-12-17 18:17:53 +02:00
|
|
|
struct CacheInfo
|
|
|
|
{
|
2023-01-30 23:15:23 +02:00
|
|
|
int id;
|
2019-12-17 18:17:53 +02:00
|
|
|
bool wantMassQuery;
|
|
|
|
int priority;
|
|
|
|
};
|
|
|
|
|
2023-01-17 20:54:47 +02:00
|
|
|
virtual std::optional<CacheInfo> upToDateCacheExists(const std::string & uri) = 0;
|
2016-04-20 15:12:38 +03:00
|
|
|
|
|
|
|
virtual std::pair<Outcome, std::shared_ptr<NarInfo>> lookupNarInfo(
|
2016-04-21 18:53:47 +03:00
|
|
|
const std::string & uri, const std::string & hashPart) = 0;
|
2016-04-20 15:12:38 +03:00
|
|
|
|
|
|
|
virtual void upsertNarInfo(
|
2016-04-21 18:53:47 +03:00
|
|
|
const std::string & uri, const std::string & hashPart,
|
2018-09-25 19:54:16 +03:00
|
|
|
std::shared_ptr<const ValidPathInfo> info) = 0;
|
2021-05-06 17:45:09 +03: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 15:12:38 +03:00
|
|
|
};
|
|
|
|
|
2023-04-07 16:55:28 +03:00
|
|
|
/**
|
|
|
|
* Return a singleton cache object that can be used concurrently by
|
|
|
|
* multiple threads.
|
|
|
|
*/
|
2016-04-20 15:12:38 +03:00
|
|
|
ref<NarInfoDiskCache> getNarInfoDiskCache();
|
|
|
|
|
2023-01-30 23:15:23 +02:00
|
|
|
ref<NarInfoDiskCache> getTestNarInfoDiskCache(Path dbPath);
|
|
|
|
|
2016-04-20 15:12:38 +03:00
|
|
|
}
|