# AshCache v0.1.0 - Table of Contents

> Caches Ash reads, generic actions and calculations, and clears the cache when the data changes through Ash.

## Pages

- [Home](readme.md)

- Topics
  - [Examples](examples.md)
  - [When the cache clears](clearing.md)
  - [How AshCache works](how-it-works.md)
  - [Storage](storage.md)
  - [How to test with AshCache](testing.md)

- Reference
  - [AshCache.Resource](dsl-ashcache-resource.md)

- About AshCache
  - [Changelog](changelog.md)

## Modules

- [AshCache.CachedAction](AshCache.CachedAction.md): One cached generic action and its own settings. Takes the same options as
`AshCache.CachedRead`.

- [AshCache.CachedCalculation](AshCache.CachedCalculation.md): One cached module calculation and its own settings: how long its entries
live and what is passed to the store adapter. `nil` and `[]` results are
real answers, so they are always cached.

- [AshCache.CachedRead](AshCache.CachedRead.md): One cached read action and its own settings: how long its entries live,
whether empty results are kept, and what is passed to the store adapter.

- [AshCache.Calculations.CalculateThrough](AshCache.Calculations.CalculateThrough.md): Caching for a module calculation, one entry per record.

- Public API
  - [AshCache](AshCache.md): Declarative read-through caching for Ash read and generic actions. See
`AshCache.Resource` for the DSL and `README.md` in this directory for the design.
  - [AshCache.Resource](AshCache.Resource.md): Caches the read and generic actions you declare, each with its own lifetime.
  - [AshCache.Supervisor](AshCache.Supervisor.md): Starts every cache store declared by the app's resources — the "zero
manual init" half of the extension. Add it once to the application's
supervision tree
  - [AshCache.Testing](AshCache.Testing.md): Lets a test see the cache events its own code caused, even when many
tests run at the same time (`async: true`).

- Configuration
  - [AshCache.Info](AshCache.Info.md): Read a resource's `cache do ... end` configuration.
  - [AshCache.Refresh](AshCache.Refresh.md): One refresh-after-write declaration: after a successful create or update,
re-run `read` (with arguments taken from the written record) so the fresh
value is cached before anyone asks for it.

- How it works
  - [AshCache.Actions.RunThrough](AshCache.Actions.RunThrough.md): Caching for a generic action.
  - [AshCache.CacheVersion](AshCache.CacheVersion.md): Per-resource cache version counter, stored in the same store
as the cached entries.
  - [AshCache.Changes.InvalidateCache](AshCache.Changes.InvalidateCache.md): Invalidates a resource's cached reads after a successful write by bumping
the resource's cache version (see `AshCache.CacheVersion`).
  - [AshCache.Coalesce](AshCache.Coalesce.md): Lets identical cache misses on one server share a single data-layer read.
  - [AshCache.Dependencies](AshCache.Dependencies.md): Which other resources a read's result was computed from.
  - [AshCache.Key](AshCache.Key.md): Builds deterministic cache keys for cached read and generic actions.
  - [AshCache.Preparations.ReadThrough](AshCache.Preparations.ReadThrough.md): Read-through caching for a read action.
  - [AshCache.Resource.Transformers.AttachCacheHooks](AshCache.Resource.Transformers.AttachCacheHooks.md): Wires caching into the resource's actions at compile time
  - [AshCache.Resource.Verifiers.ValidateCacheBlock](AshCache.Resource.Verifiers.ValidateCacheBlock.md): Rejects a `cache` block that names an action of the wrong type, declares
the same action twice, refreshes a read it does not cache, or lists in
`clear_when_changed` a module that is not a resource using AshCache.
A typo in any of these would silently cache or clear nothing.

- Storage
  - [AshCache.Store](AshCache.Store.md): Facade over the configured storage adapter.
  - [AshCache.Store.Adapter](AshCache.Store.Adapter.md): Behaviour every AshCache storage adapter implements.
  - [AshCache.Store.Adapters.Cachex](AshCache.Store.Adapters.Cachex.md): The production store: one Cachex instance per declared cache, started by
`AshCache.Supervisor`.
  - [AshCache.Store.Adapters.Nebulex](AshCache.Store.Adapters.Nebulex.md): Experimental: not yet tested on real servers.
  - [AshCache.Store.Adapters.Noop](AshCache.Store.Adapters.Noop.md): Adapter that stores nothing: every read is a miss. Swapping this in
disables caching entirely without touching any resource.

  - [AshCache.Store.Adapters.ProcessLocal](AshCache.Store.Adapters.ProcessLocal.md): Process-dictionary adapter: every process sees its own private cache,
which makes `async: true` tests isolated with zero setup.

