View Source Cachex.Services (Cachex v3.6.0)

Service specification provider for Cachex caches.

Services can either exist for the global Cachex application or on a cache level. This module provides access to both in an attempt to group all logic into one place to make it easier to see exactly what exists against a cache and what doesn't.

Link to this section Summary

Functions

Returns a list of workers of supervisors for the global app.

Returns a list of workers or supervisors for a cache.

Retrieves the process identifier of the provided service.

Returns a list of all running cache services.

Link to this section Functions

@spec app_spec() :: [Supervisor.Spec.spec()]

Returns a list of workers of supervisors for the global app.

This will typically only be called once at startup, but it's separated out in order to make it easier to find when comparing supervisors.

At the time of writing, the order does not matter - but that does not mean this will always be the case, so please be careful when modifying.

@spec cache_spec(Supervisor.Spec.cache()) :: [Supervisor.Spec.spec()]

Returns a list of workers or supervisors for a cache.

This is used to set up the supervision tree on a cache by cache basis, rather than embedding all of this logic into the parent module.

Definition order here matters, as there's inter-dependency between each of the child processes (such as the Janitor -> Locksmith).

@spec locate(Supervisor.Spec.cache(), atom()) :: pid() | nil

Retrieves the process identifier of the provided service.

This will return nil if the service does not exist, or is not running.

@spec services(Supervisor.Spec.cache()) :: [Supervisor.Spec.spec()]

Returns a list of all running cache services.

This is used to view the children of the specified cache, whilst filtering out any services which may not have been started based on the cache options.