ReleaseKit.PackageCache (ReleaseKit v0.3.0)

Copy Markdown

Tracks package inputs so unchanged release directories can reuse artifacts.

The cache stores per-file metadata beside the manifest. A hit is valid only when the tarball, checksum sidecar, manifest, and cache file all exist and the current fingerprint matches the cached fingerprint.

Like Mix compilers, the cache uses file size and mtime as the fast path and only hashes file contents when metadata changed or a file is new.

Summary

Functions

Fingerprints a release directory plus package contexts.

Returns true when an existing package can be reused for the fingerprint.

Returns the cache file path associated with a manifest path.

Records the package bytes associated with a cache entry.

Returns a reusable package source for unchanged release content.

Writes a package cache entry.

Types

t()

@type t() :: %ReleaseKit.PackageCache{
  checksum: String.t() | nil,
  content_fingerprint: binary(),
  entries: [ReleaseKit.PackageCache.Entry.t()],
  fingerprint: binary(),
  tarball: Path.t() | nil,
  version: pos_integer()
}

Functions

fingerprint(cache_path, release_dir, artifact_context, content_context)

@spec fingerprint(Path.t(), Path.t(), term(), term()) :: t()

Fingerprints a release directory plus package contexts.

hit?(cache_path, tarball, checksum_path, manifest_path, cache)

@spec hit?(Path.t(), Path.t(), Path.t(), Path.t(), t()) :: boolean()

Returns true when an existing package can be reused for the fingerprint.

path(manifest_path)

@spec path(Path.t()) :: Path.t()

Returns the cache file path associated with a manifest path.

put_package(cache, tarball, checksum)

@spec put_package(t(), Path.t(), String.t()) :: t()

Records the package bytes associated with a cache entry.

reuse_source(cache_path, content_fingerprint)

@spec reuse_source(Path.t(), binary()) :: {:ok, Path.t(), String.t()} | :miss

Returns a reusable package source for unchanged release content.

write!(cache_path, cache)

@spec write!(Path.t(), t()) :: :ok

Writes a package cache entry.