Superbol_cache.TypesPublic type definitions for the SuperBOL dependency-aware cache.
Terminology: a witness records an observation made while producing a cached value --- the contents of a file that was read, the listing of a directory that was searched, the status of an environment variable that was consulted, or the key of another entry that was reused. A manifest gathers the witnesses observed for one entry, along with the digest of the value that was produced.
An entry is looked up via a shallow key, computed from what is known before the work is performed. The shallow key locates the manifest; a hit additionally requires every recorded witness to still hold.
Digest of some contents; holds the raw (16-byte) output of Digest.string, not its hexadecimal rendering.
type witness = | File of {name : string;canonical path of the file that was read
*)digest : digest;digest of its contents
*)}| Dir of {name : string;canonical path of the directory searched
*)digest : digest;digest of its sorted, canonical listing
*)}| Env of {var : string;name of the variable that was consulted
*)value : string option;None iff it was unset
}| Sub of {key : key;entry whose value was reused
*)}An observation whose invalidation entails a miss on the entry that recorded it.
Paths carried by File and Dir are canonical in the sense of Superbol_cache.Canon; they need not be meaningful on any machine other than the one that recorded them.
type manifest = {manifest_label : string;caller-chosen; for monitoring only
*)manifest_witnesses : witness list;manifest_object : digest;digest of the associated value
*)}Everything recorded about one entry, besides its value.
Why a stored item could not be read back.
Note that a Bad_version_tag is expected in normal operation: it is how entries left behind by a different producer are skipped.
type error = | Unreadable of read_error| Storage of stringunderlying storage reported a failure
*)| Cycle of key listSub witnesses form a cycle
Why a cache operation could not be carried out. Every variant denotes a condition under which the caller should proceed as though the cache were empty; none of them is an error the caller needs to handle.
type prune_policy = | Neverno entry is ever removed automatically
*)| Bounded of {max_age : float option;Reclaim entries that have not been hit for that many seconds.
*)max_size : int64 option;Keep the whole cache --- entries and the values they hold --- under that many bytes, by reclaiming those least recently used.
*)}When entries are reclaimed.
The bounds of Bounded compose: an entry goes if any of them says so, and leaving them all unset reclaims nothing but the leftovers of instances that died mid-write.