Roux.Stamp (roux v0.2.2)

Copy Markdown View Source

A value computed from files, kept for as long as the files' stat stamps say they have not changed: memo/4.

Roux.Stamp.memo({:solver_version, bin}, [bin], fn -> version_of(bin) end, store: store)

A stamp is a file's size, modification time, inode and change time (or its absence). The value is kept per VM, and — with store: — in a Roux.Blob store's action cache under the key and the stamps, so a fresh VM whose files have not moved reads it back instead of computing it. A value computed while a file was written within the last recent: seconds is not kept: a stamp that young may not show a write that follows it within the same second. Neither is :error or {:error, _}.

Summary

Functions

Drops every value this VM keeps (memo/4); a store's stay.

The value compute gives from files, kept under key while the files' stamps hold (see the moduledoc).

A file's stamp: {size, mtime, inode, ctime} (POSIX seconds), or :absent.

Functions

forget()

@spec forget() :: :ok

Drops every value this VM keeps (memo/4); a store's stay.

memo(key, files, compute, opts \\ [])

@spec memo(term(), [Path.t()], (-> value), keyword()) :: value when value: var

The value compute gives from files, kept under key while the files' stamps hold (see the moduledoc).

Options

  • :store — a Roux.Blob store to keep the value in across VMs;
  • :recent — seconds within which a file's stamp is not trusted (default 2).

stamp(path)

@spec stamp(Path.t()) ::
  {non_neg_integer(), integer(), integer(), integer()} | :absent

A file's stamp: {size, mtime, inode, ctime} (POSIX seconds), or :absent.