# `SuperWorker.TermStorage`
[🔗](https://github.com/ohhi-vn/super_worker/blob/main/lib/supervisor/term_storage.ex#L1)

A thin wrapper around `:persistent_term` for storing terms that are rarely
updated and read from many processes on the node.

Keys are prefixed with this module's name so they cannot collide with other
`:persistent_term` users. All operations run in the calling process — there
is no server process, so reads are as fast as `:persistent_term` lookups.

Keep in mind that updating a `:persistent_term` key triggers a global GC
scan on all schedulers; use it for config-like data, not hot counters.

## Examples

    iex> TermStorage.put(:my_key, %{a: 1})
    iex> TermStorage.get(:my_key)
    {:ok, %{a: 1}}

    iex> TermStorage.get(:never_put)
    {:error, :not_found}

# `delete`

```elixir
@spec delete(term()) :: :ok
```

Delete the key from the storage.

# `get`

```elixir
@spec get(term()) :: {:ok, term()} | {:error, :not_found}
```

Get the value of the key from the storage.

Returns `{:ok, value}` (including stored `nil` values) or
`{:error, :not_found}` when the key was never put.

# `get_all`

```elixir
@spec get_all() :: [{term(), term()}]
```

Get all key/value pairs stored by this module.

Keys are returned as given to `put/2` (the internal module prefix is
stripped).

# `put`

```elixir
@spec put(term(), term()) :: :ok
```

Put the value of the key to the storage.

Returns `:ok`.

---

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