Closed slashmili closed 8 years ago
:no_update
support has been merged, but the new hex package has not yet been released. Could you please try pointing your dependency to the GitHub master and see if it works? If you need this feature now, I could release 0.11.0, but I'd like to confirm first it works for you with the current master.
I'm trying to write a counter which gets expired after a time period, I doesn't work as I expected.
This is the test case that I expect to work but it doesn't.
test "second update shouldn't clear key's orignial ttl" do
update_fn = fn(value) ->
case value do
nil -> {:ok, 1}
_ -> {:ok, %ConCache.Item{value: value + 1, ttl: :no_update}}
end
end
with_cache(
[ttl_check: 10,ttl: 50],
fn(cache) ->
ConCache.update(cache, :a, &update_fn.(&1))
assert ConCache.get(cache, :a) == 1
ConCache.update(cache, :a, &update_fn.(&1))
assert ConCache.get(cache, :a) == 2
:timer.sleep(40)
refute ConCache.get(cache, :a)
end)
end
It works if I change my update_fn to:
update_fn = fn(value) ->
case value do
nil -> {:ok, %ConCache.Item{value: value + 1, ttl: 50}}
_ -> {:ok, %ConCache.Item{value: value + 1, ttl: :no_update}}
end
end
But I suppose the first one should also work, right? I expect during update if I return {:ok, 1} ConCache would honor the configured ttl and uses that one. However looks like that it creates an item in cache without ttl
It's more related to ConCache.update
so I close this issue.
I'll update you if :no_cache works properly later
Hi,
I am using
con_cache
version0.10.0
When I run these commands I face an error :
Something strange is going on, I wanted to reproduce the same problem in
con_cache
tests but the same code works on the test