Amarula.MessageSecretStore.ETS (amarula v0.5.2)
View SourceIn-memory Amarula.MessageSecretStore adapter — the default.
One named ETS table per connection profile, holding
{msg_id, ts, secret, sender}. State is lost on restart, which is usually
fine: a message edit lands within minutes of the original (point a
Amarula.MessageSecretStore.ReadOnly adapter at your own store if you need
edits to survive restarts).
Bound
Entries live for :ttl_ms (default 15 minutes — WhatsApp's edit window; a
secret older than that can't correspond to a still-editable message). Reads
lazily skip expired entries, and every write sweeps them, so the table holds
at most ~one edit window of inbound traffic.
Ownership
The table is created by ensure_local/2, called from Connection.init, so it
is owned by the Connection process, named by profile, and dies (recreated
empty) with it — a poisoned entry can never outlive the restart it triggers.
Unlike the retry cache's table it is :protected, not :public: only the
Connection process ever reads or writes it (both the stash on receive and the
lookup on edit happen in handle_message).
Options
:ttl_ms— how long a secret is retained (default 900000).
Summary
Functions
Create the profile's table, owned by the calling process (Connection).
Called from Connection.init before any reader — no create race. Idempotent.