Why I cannot use tuple as application env key?

borja.deregil borja.deregil@REDACTED
Thu Oct 29 14:39:01 CET 2020

> I want to use tuple as application env key:
> application:set_env(sessions, {backend,Name},  Configuration).
> Why is it forbidden? Why application_controller assumes that I must
> use only atoms?

If you use application:set_env/1 or application:set_env/2, you're right 
application_controller will check that your key is an atom.
If you use application:set_env/3, you can use any term as key (I just 
tried locally).


> You can try to use persistent option and will see that it doesn't work.

Can you share what doesn't work? I can recommed the approach shared by 
bengt, use
application:get_env/2 at the beggining of your application, and use 
persistent_term or and
ETS table to store configuration in the format that you want. Both ETS 
and persistent_term
allow any Erlang term as the key.


More information about the erlang-questions mailing list