# `TuningFork.Cache`
[🔗](https://github.com/jaman/tuning_fork/blob/v0.1.3/tuning_fork/lib/tuning_fork/cache.ex#L1)

Keeps rendered audio on disk, keyed by name and fingerprint.

    Cache.fetch("game/dusk", Cache.fingerprint(Game.Music), fn -> render() end)

# `clear`

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

Remove the cache directory and everything in it, whatever fingerprint it was stored under.

# `dir`

```elixir
@spec dir() :: Path.t()
```

The directory audio is kept in: `$XDG_STATE_HOME/tuning_fork`, or
`~/.local/state/tuning_fork` when that is unset or relative.

# `fetch`

```elixir
@spec fetch(String.t(), String.t(), (-&gt; binary())) :: binary()
```

The stored audio for `key`, rendering and storing it when there is none.

`key` names the audio and may contain path separators. `fingerprint` is any string that
changes when the rendered result should change. `render` is called only on a miss, and its
binary is both stored and returned. A store that fails is logged at debug level and the
binary is still returned.

# `fingerprint`

```elixir
@spec fingerprint(module()) :: String.t()
```

A fingerprint of `module`, as a hexadecimal string.

Changes when the compiled code of `module`, `TuningFork.Voice` or `TuningFork.Mixer` changes.

# `path`

```elixir
@spec path(String.t(), String.t()) :: Path.t()
```

Where `key` at `fingerprint` is kept.

---

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