View Source Cachex.Services.Courier (Cachex v3.6.0)

Dispatch service to retrieve values from remote calls.

The Courier provides the main implementation for fallbacks triggered by calls to the fetch() command. It acts as a synchronized execution for tasks to avoid duplicating calls when loading.

The Courier uses a very simple algorithm to determine when to execute a fallback, so there's very little overhead to synchronizing calls through it. As tasks are dispatched via spawned processes, there's very little action actually happening in the service process itself.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Dispatches the Courier to execute a task.

Starts a new Courier process for a cache.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

dispatch(cache, key, task)

View Source
@spec dispatch(Spec.cache(), any(), (() -> any())) :: any()

Dispatches the Courier to execute a task.

The task provided must be a closure with arity 0, in order to simplify the interfaces internally. This is a blocking remote call which will wait until a result can be loaded.

@spec start_link(Spec.cache()) :: GenServer.on_start()

Starts a new Courier process for a cache.