# `Cache.PersistentTerm`
[🔗](https://github.com/mikaak/elixir_cache/blob/main/lib/cache/persistent_term.ex#L1)

`:persistent_term` adapter for storing rarely-written, frequently-read cached values.

This adapter stores values in Erlang's `:persistent_term` storage, which provides
extremely fast read access at the cost of more expensive writes and deletes.
It is best suited for configuration values or other data that changes infrequently.

TTL is not supported — values persist until explicitly deleted.

## Example

```elixir
defmodule MyApp.Cache do
  use Cache,
    adapter: Cache.PersistentTerm,
    name: :my_app_persistent_cache,
    opts: []
end
```

# `child_spec`

Returns a specification to start this module under a supervisor.

`arg` is passed as the argument to `Task.start_link/1` in the `:start` field
of the spec.

For more information, see the `Supervisor` module,
the `Supervisor.child_spec/2` function and the `t:Supervisor.child_spec/0` type.

# `native_term_storage?`

`:persistent_term` exists to hand out zero-copy references to already-built terms.
Encoding a value into a binary and decoding it on every read defeats the entire
point of the adapter, so it never encodes.

---

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