# `AshCache.Actions.RunThrough`
[🔗](https://github.com/Undeadlol1/ash_cache/blob/v0.1.0/lib/ash_cache/actions/run_through.ex#L1)

Caching for a generic action.

Ash has no way for a hook to skip a generic action's `run`, so
`AshCache.Resource.Transformers.AttachCacheHooks` puts this module in the
action's place and hands it the original `run` as the `:run` option. On a
hit the original is never called; on a miss it is called and a successful
result is cached.

Ash checks authorization before calling `run`, so a hit is still
authorized. Hooks, `allow_nil?` and loading of the result run on a hit too.

The key holds the action's arguments, the actor and the tenant
(`AshCache.Key`). Errors, `nil` and (unless `cache_empty?: true`) `[]` are
not cached. `Ash.ActionInput.set_context(input, %{ash_cache: :bypass})`
skips the cache for one call.

Like reads, the key also holds the version of each resource listed in
`clear_when_changed`, and identical misses on one server share one `run`
call (`AshCache.Coalesce`).

---

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