Sovite.Core.Repo.Tables.DomainCache (sovite v0.2.0)

Copy Markdown View Source

Keeps the domains of Sovite.Core.Repo.Tables.Domains in :persistent_term, so every recipient check can read them without a database query.

The list is read at start and every :interval (default 10 seconds). When the database cannot be read, the last list stays in use.

Options

  • :repo - the Sovite.Core.Repo reference. Required.
  • :id - names the cache, for classes/1. Defaults to id/1 of the repo.
  • :interval - milliseconds between refreshes.

Telemetry

  • [:sovite, :domains, :error] - %{}, %{reason}

Summary

Functions

The cached domains of cache id: name to class. Empty before the first read.

The cache ID for Sovite's database repo.

Starts the cache.

Functions

classes(id)

@spec classes(term()) :: %{
  required(String.t()) => Sovite.Core.Repo.Schemas.Domain.kind()
}

The cached domains of cache id: name to class. Empty before the first read.

id(arg)

@spec id(Sovite.Core.Repo.t()) :: term()

The cache ID for Sovite's database repo.

start_link(opts)

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

Starts the cache.