Application.put_env and timeout

I want to store an environment variable that can be read elsewhere in my app. So plan to use Application.put_env. But I read that it is an opt that is a timeout. Does that mean after 5 seconds (default timeout) the environment variable goes away? I want it to last the lifetime of my app.

No, it means that putting env value is not instant and is not guaranteed.
Application.put_env/4 uses application:set_env/4 under the hood, so you can refer to its docs directly application — kernel v10.0.1

set_env/4 uses the standard gen_server time-out value (5000 ms). Option timeout can be specified if another time-out value is useful, for example, in situations where the application controller is heavily loaded.

I assume your application controller is not heavily loaded, so just don’t bother with this option

1 Like