mirror of
https://git.youjo.love/youjo/youjo-be.git
synced 2024-11-20 13:59:55 +01:00
rich media: parser: cache negatives
This commit is contained in:
parent
8fb16e9f0f
commit
83b7062634
1 changed files with 9 additions and 7 deletions
|
@ -15,11 +15,13 @@ defmodule Pleroma.Web.RichMedia.Parser do
|
|||
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 @@ defmodule Pleroma.Web.RichMedia.Parser do
|
|||
|
||||
html |> maybe_parse() |> get_parsed_data()
|
||||
rescue
|
||||
_e ->
|
||||
{:error, "Parsing error"}
|
||||
e ->
|
||||
{:error, "Parsing error: #{inspect(e)}"}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue