Why is it that only after running Blog.Cache.get key, Blog.Cache.to_map is updated? How do I refresh the stored data? Are there any computer science concept related with on-memory cache involved?
since this deals with ttl (of 10 seconds) you should post a function akin to the one in the readme, that uses :timer.sleep and then tell us what the unexpected behaviour is:
# Now it is ready to be used from any other module. Here is an example:
defmodule MyApp.Test do
alias MyApp.Cache
alias Nebulex.Object
def test do
Cache.set "foo", "bar", ttl: 2
"bar" = Cache.get "foo"
true = Cache.has_key? "foo"
%Object{key: "foo", value: "bar"} = Cache.get "foo", return: :object
:timer.sleep(2000)
nil = Cache.get "foo"
nil =
"foo"
|> Cache.set("bar", return: :key)
|> Cache.delete(return: :key)
|> Cache.get
end
end