Understanding concache global_ttl and time expiry

I’m looking at someone’s code and they have something like this

  def concache_sup(name, opts \\ []) do
    Supervisor.child_spec(
      {
        ConCache,
        [
          name: name,
          ttl_check_interval: 10_000,
          global_ttl: 60_000,
          touch_on_read: true
        ]
      },
      id: {ConCache, name}
    )
  end

What is the unit for global_ttl? 60,000 milliseconds? And is that the time how long the cache lasts?

It’s IMO well-explained. Do you struggle with anything in there?

The documentation uses :timer.seconds
I’m not sure what that returns. Is that returning an integer representing seconds? So in my code the TTL is actually 60,000 seconds?

Check this out:

iex(1)> :timer.seconds(1)
1000

No, 60_000 refers to 60k milliseconds i.e. 60 seconds.

1 Like