# `MishkaCmsCore.Runtime.States.RedirectsState`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/runtime/states/redirects_state.ex#L5)

ETS copy of the active `MishkaCmsCore.Runtime.Redirect` rules, so a request is answered without a
query.

The same shape as `MishkaCmsCore.Runtime.States.TranslationsState`, for the same reasons: loaded
once at boot, then kept current off the resource's own PubSub broadcasts, which reach every node —
a rule saved on one server is served by all of them without a restart. Nothing is read again until
a rule changes.

Each entry is `{{site_id, from_path}, id, to, status}`; a second table maps a rule's id to its key,
so a rule whose `from_path` changed, or that was archived, deactivated or deleted, leaves its old
key behind it. Only active, unarchived rules are kept.

Every change is heard on `runtime:state:redirect:changed` with `%{op: :save | :delete, key: id}`.

Started by the host after `Phoenix.PubSub` and before the endpoint, like the other states:

    MishkaCmsCore.Runtime.States.RedirectsState,

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `lookup`

```elixir
@spec lookup(String.t(), String.t()) :: {String.t(), pos_integer()} | nil
```

The rule `site_id` serves for `path` — a key `MishkaCmsCore.Runtime.Redirects` built — as
`{to, status}`, else `nil`.

One lookup, no GenServer hop. Never raises: a table that is not there yet is the same as one with
nothing in it, so a request answered before this process starts is served as if no rule existed.

# `refresh`

```elixir
@spec refresh() :: :ok
```

Reload every rule from the database.

# `start_link`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
