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}
Summary
Functions
Delete the key from the storage.
Get the value of the key from the storage.
Get all key/value pairs stored by this module.
Put the value of the key to the storage.
Functions
@spec delete(term()) :: :ok
Delete the key from the storage.
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 key/value pairs stored by this module.
Keys are returned as given to put/2 (the internal module prefix is
stripped).
Put the value of the key to the storage.
Returns :ok.