Ferricstore.FetchOrCompute (ferricstore v0.11.0)

Copy Markdown View Source

Coordinates fenced cache-aside computation leases.

Keys are routed through a fixed PartitionSupervisor, so unrelated cache misses do not serialize through one process. Each partition coalesces local waiters per key and monitors both the compute owner and any shared remote poller. Failures are replicated as short-lived opaque outcomes so waiters on other nodes observe them without issuing writes while polling.

Summary

Types

compute_token()

@type compute_token() :: binary()

fetch_result()

@type fetch_result() ::
  {:hit, binary()}
  | {:compute, binary(), compute_token()}
  | {:ok, binary()}
  | {:error, term()}

Functions

child_spec(opts)

@spec child_spec(keyword()) :: Supervisor.child_spec()

default_compute_timeout_ms()

fetch_or_compute(key, ttl_ms, hint)

@spec fetch_or_compute(binary(), pos_integer(), binary()) :: fetch_result()

fetch_or_compute(ctx, key, ttl_ms, hint)

@spec fetch_or_compute(FerricStore.Instance.t(), binary(), pos_integer(), binary()) ::
  fetch_result()

fetch_or_compute_error(key, token, error_msg)

@spec fetch_or_compute_error(binary(), compute_token(), binary()) ::
  :ok | {:error, term()}

fetch_or_compute_error(ctx, key, token, error_msg)

@spec fetch_or_compute_error(
  FerricStore.Instance.t(),
  binary(),
  compute_token(),
  binary()
) :: :ok | {:error, term()}

fetch_or_compute_result(key, value, token, ttl_ms)

@spec fetch_or_compute_result(binary(), binary(), compute_token(), non_neg_integer()) ::
  :ok | {:error, term()}

fetch_or_compute_result(ctx, key, value, token, ttl_ms)

@spec fetch_or_compute_result(
  FerricStore.Instance.t(),
  binary(),
  binary(),
  compute_token(),
  non_neg_integer()
) :: :ok | {:error, term()}

start_link(opts \\ [])

@spec start_link(keyword()) :: Supervisor.on_start()