I am building an application that makes heavy use of Process.send_after/4
. This documentation states send_after
returns a reference()
.
My understanding was that mnesia could store any native erlang data type, of which a reference()
appears to be one. However, I seem to remember seeing a forum post about mnesia and it’s inability to store pid()
.
My mnesia table is created with:
:mnesia.create_table(Completions, [attributes: [:name, :expires_at, :reaper_timer], disc_copies: [node()]])
When I try to store the reference()
in my mnesia table I get:
{:aborted, {:bad_type, {Completions, "asdf", #Reference<0.1626103600.603717633.51350>}}}
Ultimately I was hoping for a ttl mechanism in mnesia. Failing that I implemented the feature with a process-per timer solution. However given that I could have tens of millions of these timers, I was not super-excited about immediately scaling to 10M+ processes. I know it should be reasonably doable, but it seems like there should be easier ways.
I am definitely working on other workarounds/solutions, but this is a question that has been nagging at me for some time.
Thoughts? Comments? Corrections?