mem icon indicating copy to clipboard operation
mem copied to clipboard

Caching Fails on Restart

Open Lazarus404 opened this issue 7 years ago • 3 comments

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

Lazarus404 avatar Aug 23 '17 20:08 Lazarus404

can you show me you code using mem? you should set persistence: true when use Mem and config mnesia dir in the config.exs.

falood avatar Aug 23 '17 21:08 falood

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

Lazarus404 avatar Aug 24 '17 05:08 Lazarus404

Hi @Lazarus404 I tested it these days, but I can't reproduce it. So I have to ask you more question about this issue.

  1. your erlang and elixir version.
  2. how you redeploy and restart the app?
  3. make sure the default_ttl in options means seconds
  4. 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.

falood avatar Aug 28 '17 04:08 falood