3 ms·
ets tables are the goto for data structures (for example the :digraph module that ships with elixir is built on an ets table, presumably because A* needs a muta
by throwawaymaths 1y ago
ets tables are the goto for data structures (for example the :digraph module that ships with elixir is built on an ets table, presumably because A* needs a mutable datatype)
Process dictionary is also an option.
Can always use a genserver as a data store (but only do that if lifetime shenanigans make it make sense)
Postgres is also an option. Sqlite if you don't want to stand up a service.
- hinkley 1y agoAh yes. I’m using a genserver to persist a countdown clock across page loads. ETS gives me a memory leak vibe but I need to bite the bullet and learn to use it properly.
- throwawaymaths 1y agoThink of ets as an arena. You can clear the whole table by yanking its owning process. This could even be made automatic by linking it to whatever process needs the ets table.
- hinkley 1y agoHmmm. Maybe I’m misremembering some Erlang release notes then.