try with Cachex.get - not sure a fetch exists - Cachex — Cachex v4.1.1
so maybe:
def get_cached_result!(slug) do
Cachex.get(:my_cache, "key_#{slug}", fn(slug) ->
Repo.get_by!(MyRecord, slug: slug, parent_id: 0)
end)
end
fwiw I have this from some old code (untested recently):
{ _status, post } = Cachex.get(:my_cache, "post_#{id}", fallback: fn(_params) ->
Post
|> Repo.get!(id)
|> Repo.preload([:comments])
end)
EDIT: from a quick look: fetch is being added in Cachex 3.0 - so thats probably why you find it on the github examples:/


















