Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
cache.hh
Go to the documentation of this file.
1#pragma once
3
5#include "nix/store/path.hh"
6
7namespace nix::fetchers {
8
13struct Cache
14{
15private:
16 /* VTable anchor to avoid weak linkage of the vtable - it breaks
17 dynamic_cast across shared libraries on Darwin. */
18 virtual void anchor();
19public:
20 virtual ~Cache() {}
21
26 using Domain = std::string_view;
27
31 using Key = std::pair<Domain, Attrs>;
32
36 virtual void upsert(const Key & key, const Attrs & value) = 0;
37
41 virtual std::optional<Attrs> lookup(const Key & key) = 0;
42
47 virtual std::optional<Attrs> lookupWithTTL(const Key & key) = 0;
48
49 struct Result
50 {
51 bool expired = false;
52 Attrs value;
53 };
54
59 virtual std::optional<Result> lookupExpired(const Key & key) = 0;
60
66 virtual void upsert(Key key, Store & store, Attrs value, const StorePath & storePath) = 0;
67
69 {
70 StorePath storePath;
71 };
72
77 virtual std::optional<ResultWithStorePath> lookupStorePath(Key key, Store & store) = 0;
78
83 virtual std::optional<ResultWithStorePath> lookupStorePathWithTTL(Key key, Store & store) = 0;
84};
85
86} // namespace nix::fetchers
std::map< std::string, Attr > Attrs
Definition attrs.hh:68
Definition path.hh:33
Definition store-api.hh:397
Definition cache.hh:50
Definition cache.hh:14
virtual void upsert(Key key, Store &store, Attrs value, const StorePath &storePath)=0
virtual std::optional< ResultWithStorePath > lookupStorePath(Key key, Store &store)=0
std::string_view Domain
Definition cache.hh:26
virtual std::optional< Attrs > lookup(const Key &key)=0
virtual std::optional< Attrs > lookupWithTTL(const Key &key)=0
virtual std::optional< ResultWithStorePath > lookupStorePathWithTTL(Key key, Store &store)=0
virtual std::optional< Result > lookupExpired(const Key &key)=0
std::pair< Domain, Attrs > Key
Definition cache.hh:31
virtual void upsert(const Key &key, const Attrs &value)=0