Settings that survive restarts and power cuts, for apps.
NestGen2.Storage.put(:screen, %{idle_timeout_ms: 30_000})
NestGen2.Storage.get(:screen, %{idle_timeout_ms: :infinity})Each app gets its own folder in flash that nothing else touches,
<install>/data/<app>, and each key is one file in it, holding an Erlang
term as readable text (cat shows it) with a checksum. Writes are made safe
against the power going mid-write: the new value goes to a temporary file
that is flushed to flash, the previous value is kept as a backup, and the
temporary file is then renamed into place. A value that doesn't check out
when read falls back to the backup, then to the default; it never raises.
Meant for settings and small state that change now and then, not for data written every second: the Nest's flash is slow and wears out.
For anything more (logs, a cache, a database such as CubDB), dir/1 is the
app's own folder to use as it likes.
Keys are atoms or strings of lowercase letters, digits and underscores.
Values are any term that can be written out and read back as text: maps,
lists, tuples, strings, numbers, atoms; not pids, references or functions.
The calling process's application is used unless app: is given.
Summary
Functions
Removes key.
The app's own folder in flash (created if missing).
The value stored under key, or default.
The keys stored, as strings.
Stores value under key.
Types
Functions
Removes key.
The app's own folder in flash (created if missing).
The value stored under key, or default.
The keys stored, as strings.
@spec put(key(), term(), keyword()) :: :ok | {:error, :not_storable | File.posix()}
Stores value under key.