Commit 83b70626 authored by kaniini's avatar kaniini
Browse files

rich media: parser: cache negatives

parent 8fb16e9f
Pipeline #6732 passed with stages
in 3 minutes and 28 seconds
......@@ -15,11 +15,13 @@ def parse(nil), do: {:error, "No URL provided"}
def parse(url), do: parse_url(url)
else
def parse(url) do
with {:ok, data} <- Cachex.fetch(:rich_media_cache, url, fn _ -> parse_url(url) end) do
data
else
_e ->
{:error, "Parsing error"}
try do
Cachex.fetch!(:rich_media_cache, url, fn _ ->
{:commit, parse_url(url)}
end)
rescue
e ->
{:error, "Cachex error: #{inspect(e)}"}
end
end
end
......@@ -30,8 +32,8 @@ defp parse_url(url) do
html |> maybe_parse() |> get_parsed_data()
rescue
_e ->
{:error, "Parsing error"}
e ->
{:error, "Parsing error: #{inspect(e)}"}
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment