Module Superbol_cache.Store

Storage the cache is built upon.

Like Cobol_common.Platform, this is a record of operations rather than a set of direct system calls, so that the library itself needs no dependency on Unix: cobol_lsp links against a platform that performs no I/O at all, and the concrete implementation is injected at startup by superbol_platform. It also lets the test suite run the whole cache against in_memory, with no file-system involved.

Every path handed to a store is relative to the cache root.

What an implementation must guarantee

The cache directory may sit on a network mount, and may be written to by several users at once. An implementation is therefore required to:

Conversely, an implementation is not required to make TYPES.store.stat accurate: attribute caching makes sizes and dates stale over NFS. The cache never relies on them for correctness, only for pruning and monitoring.

module TYPES : sig ... end
val unavailable : TYPES.store

A store on which nothing can be stored. Every lookup against it misses and every write is dropped, which is precisely how the cache behaves when caching is turned off.

val entries_under : TYPES.store -> string -> (string * string) list

entries_under store dir lists the items held under the two-level fanout at dir, as pairs of an item's name and its path. Both the manifests and the values are laid out that way, and both the monitoring API and the pruner need to walk them.

val in_memory : ?now:(unit -> float) -> unit -> TYPES.store

in_memory ?now () is a store backed by a hash table. Intended for testing: it honours the same contract as a file-system store, including the non-destructive behaviour of TYPES.store.publish.