Per-session storage, scoped to a Ussd.Context's uid/gid and backed by a
pluggable Ussd.Cache.
Every key is namespaced by the caller's uid, unless public: true is passed, in
which case it's namespaced by gid instead - this is how "continuing" sessions
hand a value from one uid (the expired session) to the next (the redial), and how
pagination/truncation counters survive a state being re-entered.
record = Ussd.Record.new(context.uid, context.gid)
record |> Ussd.Record.set("otp", "1234", ttl: 300)
record |> Ussd.Record.get("otp")
Summary
Functions
Subtracts amount (default 1) from key, starting from 0 if unset, and returns the new value.
Deletes key.
Deletes several keys at once.
Reads key, or default if it isn't set (or has expired). See set/4 for :public.
Reads and decrypts a value stored with set_encrypted/4, or default if it isn't set.
Reads several keys at once, in order, each falling back to default if unset.
Whether key is currently set. Pass public: true to check the gid-scoped copy instead of the uid-scoped one.
Adds amount (default 1) to key, starting from 0 if unset, and returns the new value.
The locale last set for this session via set_locale/2, or nil.
Builds a record scoped to uid/gid. cache overrides config :ussd, :cache
(which itself defaults to Ussd.Cache.ETS) for just this record.
Stores value under key.
Like set/4, but encrypts value first (AES-256-GCM, keyed by
config :ussd, :encryption_key) so it's unreadable at rest - use for PINs,
account numbers, and other sensitive values. Read it back with get_encrypted/4,
never with plain get/4.
Persists the caller's chosen locale across requests in this session.
Like set/4, for several key => value pairs at once. Same :ttl/:public options, applied to every key.
Types
Functions
Subtracts amount (default 1) from key, starting from 0 if unset, and returns the new value.
Deletes key.
Deletes several keys at once.
Reads key, or default if it isn't set (or has expired). See set/4 for :public.
Reads and decrypts a value stored with set_encrypted/4, or default if it isn't set.
Reads several keys at once, in order, each falling back to default if unset.
Whether key is currently set. Pass public: true to check the gid-scoped copy instead of the uid-scoped one.
Adds amount (default 1) to key, starting from 0 if unset, and returns the new value.
The locale last set for this session via set_locale/2, or nil.
Builds a record scoped to uid/gid. cache overrides config :ussd, :cache
(which itself defaults to Ussd.Cache.ETS) for just this record.
Stores value under key.
Options:
:ttl- seconds until the value expires;nil(default) means it never expires on its own:public- store undergidinstead ofuid, so it's visible to a future redial under a differentuid(defaultfalse)
Like set/4, but encrypts value first (AES-256-GCM, keyed by
config :ussd, :encryption_key) so it's unreadable at rest - use for PINs,
account numbers, and other sensitive values. Read it back with get_encrypted/4,
never with plain get/4.
Persists the caller's chosen locale across requests in this session.
Like set/4, for several key => value pairs at once. Same :ttl/:public options, applied to every key.