melpon / memoize

A method caching macro for elixir using CAS on ETS.
https://hex.pm/packages/memoize
MIT License
189 stars 12 forks source link

Refresh timeout option #18

Closed gajuro closed 3 years ago

gajuro commented 3 years ago

Hello,

First, thank you for a valuable library here.

I would need a strategy option that will refresh the cache after a given timeout. Basically, the function call will wait for the execution only the first time, after that it will return the cached value.

defmemo slow_function, refresh_in: 10 * 1000 do
end

I doubt that I will be able to write a strategy myself, but still, can you give me some hints for this?

Thanks again.

melpon commented 3 years ago

Use :expires_in.