View Source ExKits.Utils.Const (ex_kits v0.2.7)

This module is similar to ets in that it provides a storage for Erlang terms that can be accessed in constant time, but with the difference that persistent_term has been highly optimized for reading terms at the expense of writing and updating terms.

When a persistent term is updated or deleted, a global garbage collection pass is run to scan all processes for the deleted term, and to copy it into each process that still uses it.

Therefore, persistent_term is suitable for storing Erlang terms that are frequently accessed but never or infrequently updated.

Summary

Functions

put a key-value pair into the persistent term storage NOTE: very very expensive, use with caution

Functions

@spec get(term()) :: term() | nil
@spec put(term(), term()) :: :ok

put a key-value pair into the persistent term storage NOTE: very very expensive, use with caution

Examples

iex> ExKits.Utils.Const.put(:key, :val)