The many ways to hold a token
summary
External API issues a short‑lived token that expires every few minutes and authentication has noticeable network latency, so naive reauth for every request doubles calls. Tried four implementations: no cache (works if traffic is low), a task that refreshes into the global app env using Process.sleep is dangerous (shared global state, brittle), a GenServer (blocks or serializes access), and a GenServer writing into ETS for parallel reads with startup races resolved by polling tests; practical winner: GenServer + ETS or no cache depending on load.
AI-written summary · about
chapters (5)
related talks
44mThe NeverEnding Application
20mUsing OTP in Your Phoenix App
46mBuilding a Realtime Websocket API in Phoenix
45mTesting Asynchronous OTP
37mKeynote: All Aboard The Stateful Train
43mUnlocking the Potential of OTP: Proven Strategies for Application Dev
46mEliminating Single Process Bottlenecks with ETS Concurrency Patterns
23mElixir GenServer: Understanding Elixir concurrency model
