- Cachex.fetch!(:object_cache, key, fn _ ->
- object = get_by_ap_id(ap_id)
-
- if object do
- {:commit, object}
- else
- {:ignore, object}
- end
- end)
+ with {:ok, nil} <- Cachex.get(:object_cache, key),
+ object when not is_nil(object) <- get_by_ap_id(ap_id),
+ {:ok, true} <- Cachex.put(:object_cache, key, object) do
+ object
+ else
+ {:ok, object} -> object
+ nil -> nil
+ end