Map of values with per-key expiry timers.
What problem this solves
TURN permissions and channel bindings expire unless refreshed. Each allocation
tracks many peers and channels, each with its own lifetime. This module wraps
a map with Process.send_after/3 so inserting or replacing a key cancels the
old timer and schedules a new expiry message to the owning process.
Internal note
Used inside allocation GenServers; not configured by operators.
RFCs
- RFC 5766 (permission and channel lifetimes)
Summary
Functions
Cancels every timer in the map and returns an empty map.
Fetches the value stored under key, ignoring the timer reference.
Returns whether key exists in the timed-entry map.
Returns all keys in the timed-entry map.
Inserts value under key, scheduling expire_msg to owner after lifetime_ms.
Removes key from the map, cancelling its timer when present.
Functions
Cancels every timer in the map and returns an empty map.
Parameters
map- timed-entry map
Fetches the value stored under key, ignoring the timer reference.
Returns whether key exists in the timed-entry map.
Returns all keys in the timed-entry map.
Parameters
map- timed-entry map
Examples
iex> ref = make_ref()
iex> map = %{"a" => {ref, 1}, "b" => {ref, 2}}
iex> Xirsys.XTurn.TimedEntry.keys(map)
["a", "b"]
Inserts value under key, scheduling expire_msg to owner after lifetime_ms.
Any existing entry for key is removed (and its timer cancelled) first.
Parameters
map- timed-entry mapkey- map key (typically peer IP or channel number)value- stored payloadlifetime_ms- milliseconds until expiry message is sentowner- process that receivesexpire_msgexpire_msg- message sent when the timer fires
Removes key from the map, cancelling its timer when present.
Parameters
map- timed-entry mapkey- map key