Don't commit nil values in object cache.

This commit is contained in:
Roger Braun 2017-05-01 16:28:40 +02:00
parent 3cb518270a
commit 108573265a
1 changed files with 8 additions and 1 deletions

View File

@ -19,7 +19,14 @@ def get_cached_by_ap_id(ap_id) do
get_by_ap_id(ap_id)
else
key = "object:#{ap_id}"
Cachex.get!(:user_cache, key, fallback: fn(_) -> get_by_ap_id(ap_id) end)
Cachex.get!(:user_cache, key, fallback: fn(_) ->
object = get_by_ap_id(ap_id)
if object do
{:commit, object}
else
{:ignore, object}
end
end)
end
end