1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-20 23:59:44 +02:00

Fetcher cache: Add support for caching facts not related to store paths

This commit is contained in:
Eelco Dolstra 2023-10-24 08:20:31 +02:00
parent fa6bc33604
commit e1b8442fa1
2 changed files with 95 additions and 0 deletions

View file

@ -10,6 +10,44 @@ struct Cache
{
virtual ~Cache() { }
/* A cache for arbitrary Attrs -> Attrs mappings with a timestamp
for expiration. */
/*
* Add a value to the cache. The cache is an arbitrary mapping of
* Attrs to Attrs.
*/
virtual void upsert(
const Attrs & inAttrs,
const Attrs & infoAttrs) = 0;
/*
* Look up a key with infinite TTL.
*/
virtual std::optional<Attrs> lookup(
const Attrs & inAttrs) = 0;
/*
* Look up a key. Return nothing if its TTL has exceeded
* `settings.tarballTTL`.
*/
virtual std::optional<Attrs> lookupWithTTL(
const Attrs & inAttrs) = 0;
struct Result2
{
bool expired = false;
Attrs infoAttrs;
};
/*
* Look up a key. Return a bool denoting whether its TTL has
* exceeded `settings.tarballTTL`.
*/
virtual std::optional<Result2> lookupExpired(
const Attrs & inAttrs) = 0;
/* Old cache for things that have a store path. */
virtual void add(
ref<Store> store,
const Attrs & inAttrs,