API Reference AshCache v#0.1.0

Copy Markdown View Source

Modules

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.

Caching for a generic action.

Per-resource cache version counter, stored in the same store as the cached entries.

One cached generic action and its own settings. Takes the same options as AshCache.CachedRead.

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.

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.

Caching for a module calculation, one entry per record.

Invalidates a resource's cached reads after a successful write by bumping the resource's cache version (see AshCache.CacheVersion).

Lets identical cache misses on one server share a single data-layer read.

Which other resources a read's result was computed from.

Read a resource's cache do ... end configuration.

Builds deterministic cache keys for cached read and generic actions.

Read-through caching for a read action.

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.

Caches the read and generic actions you declare, each with its own lifetime.

Wires caching into the resource's actions at compile time

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.

Facade over the configured storage adapter.

Behaviour every AshCache storage adapter implements.

The production store: one Cachex instance per declared cache, started by AshCache.Supervisor.

Experimental: not yet tested on real servers.

Adapter that stores nothing: every read is a miss. Swapping this in disables caching entirely without touching any resource.

Process-dictionary adapter: every process sees its own private cache, which makes async: true tests isolated with zero setup.

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

Lets a test see the cache events its own code caused, even when many tests run at the same time (async: true).