Module Cache.LocalSource

Sourcetype t
Sourceval set_build_dir : t -> Stdune.Path.t -> (t, string) Stdune.Result.t

Set the absolute path to the build directory for interpreting relative paths when promoting files.

Sourceval with_repositories : t -> Cache__.Cache_intf.repository list -> (t, string) Stdune.Result.t

Set all the version controlled repositories in the workspace to be referred to when promoting files.

Sourceval promote : t -> (Stdune.Path.Build.t * Stdune.Digest.t) list -> Key.t -> Stdune.Sexp.t list -> repository:int option -> duplication:Cache__.Cache_intf.Duplication_mode.t option -> (unit, string) Stdune.Result.t

Promote files produced by a build rule into the cache.

Find a build rule in the cache by its key.

Sourceval retrieve : t -> Cache__.Cache_intf.File.t -> Stdune.Path.t

Materialise a cached file in the build directory (using Copy or Hardlink as per the duplication mode) and return the path to it.

Sourceval deduplicate : t -> Cache__.Cache_intf.File.t -> unit

Deduplicate a file, i.e. replace the file in_the_build_directory with a hardlink to the one in_the_cache if the deduplication mode is set to Hardlink (or do nothing if the mode is Copy).

Sourceval teardown : t -> unit

Remove the local cache and disconnect with a distributed cache client if any.

Sourceval hint : t -> Key.t list -> (unit, string) Stdune.Result.t
Sourceval default_root : unit -> Stdune.Path.t

The default root directory of the local cache.

Sourcemodule Metadata_file : sig ... end

A metadata file contains a list of files produced by a cached build rule, along with some metadata that can be empty.

Sourceval promote_sync : t -> (Stdune.Path.Build.t * Stdune.Digest.t) list -> Key.t -> Stdune.Sexp.t list -> repository:int option -> duplication:Cache__.Cache_intf.Duplication_mode.t option -> (Metadata_file.t * Cache__.Cache_intf.promotion list, string) Stdune.Result.t

Like promote but also returns the resulting metadata and promotions.

Sourceval make : ?root:Stdune.Path.t -> ?duplication_mode:Cache__.Cache_intf.Duplication_mode.t -> ?log:(Stdune.User_message.Style.t Stdune.Pp.t list -> unit) -> ?warn:(Stdune.User_message.Style.t Stdune.Pp.t list -> unit) -> command_handler:(Cache__.Cache_intf.command -> unit) -> unit -> (t, string) Stdune.Result.t

Create a local cache. The only required argument is a handler for commands from the cache, such as Dedup that tell Dune that some files can be replaced with hardlinks to their cached versions. The root argument defaults to the default_root. If duplication_mode is omitted, we attempt to detect whether hardlinks are supported and use Hardlink if they are, falling back to Copy otherwise.

Sourceval duplication_mode : t -> Cache__.Cache_intf.Duplication_mode.t

The deduplication mode that was set or detected automatically (if omitted) during the local cache creation with the function make.

Sourceval overhead_size : t -> int64

The overhead size of the cache, that is, the total size of files in the cache that are not linked from any build directory.

Sourcemodule Trimming_result : sig ... end
Sourceval trim : t -> goal:int64 -> Trimming_result.t

Trim the cache by removing a set of unused files from it so that the total freed space is greater or equal to the specificed goal, in bytes. We call a cached file "unused" if there are currently no hard links to it from build directories.

Unused files are removed in the order of last access, i.e. we first remove the least recently accessed one.

We also remove all metadata files whose file references got broken during the trimming.

Sourceval garbage_collect : t -> Trimming_result.t

Purge cache metadata files that can't be read or contain references to non-existing files.

Sourceval metadata_path : t -> Key.t -> Stdune.Path.t

Path to a metadata file

Sourceval file_path : t -> Key.t -> Stdune.Path.t

Path to a data file

Sourceval tmp_path : t -> string -> Stdune.Path.t

Path to a safe, instance specific temporary directory