mem
mem copied to clipboard
Caching Fails on Restart
We're using mem to cache values that need to expire after a given time. However, on redeploying or restarting our app, the values, which we're persisting to disk, do not expire. Is this a bug or is this something we should be doing in some other way?
Thanks
can you show me you code using mem?
you should set persistence: true
when use Mem
and config mnesia dir in the config.exs
.
We're using:
defmodule Cache do
use Mem,
worker_number: 10,
default_ttl: 60 * 60 * 24,
maxmemory_size: nil,
maxmemory_strategy: :ttl,
persistence: true
end
Hi @Lazarus404 I tested it these days, but I can't reproduce it. So I have to ask you more question about this issue.
- your erlang and elixir version.
- how you redeploy and restart the app?
- make sure the
default_ttl
in options meansseconds
- make sure you won't change node name(you can check it with
Node.self()
) and the persistence data dir(config it within config.exs like here)
Thank you.