Friendship ended with Postgresql now Cachex is my best friend

This commit is contained in:
Rin Toshaka 2018-12-30 20:00:01 +01:00
parent 535fddd286
commit c119ea3a57
2 changed files with 9 additions and 8 deletions

View File

@ -76,7 +76,7 @@ def delete(%Object{data: %{"id" => id}} = object) do
def get_cached_scrubbed_html(content, scrubbers, object) do def get_cached_scrubbed_html(content, scrubbers, object) do
key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}" key = "#{generate_scrubber_signature(scrubbers)}|#{object.id}"
Cachex.fetch!(:scrubber_cache, key, fn(_key) -> ensure_scrubbed_html(content, scrubbers) end ) Cachex.fetch!(:scrubber_cache, key, fn _key -> ensure_scrubbed_html(content, scrubbers) end)
end end
def get_cached_stripped_html(content, object) do def get_cached_stripped_html(content, object) do
@ -97,11 +97,13 @@ defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
defp generate_scrubber_signature(scrubbers) do defp generate_scrubber_signature(scrubbers) do
Enum.reduce(scrubbers, "", fn scrubber, signature -> Enum.reduce(scrubbers, "", fn scrubber, signature ->
# If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0) # If a scrubber does not have a version(e.g HtmlSanitizeEx.Scrubber) it is assumed it is always 0)
version = if Kernel.function_exported?(scrubber, :version, 0) do version =
if Kernel.function_exported?(scrubber, :version, 0) do
scrubber.version scrubber.version
else else
0 0
end end
"#{signature}#{to_string(scrubber)}#{version}" "#{signature}#{to_string(scrubber)}#{version}"
end) end)
end end

View File

@ -261,5 +261,4 @@ def emoji_from_profile(%{info: _info} = user) do
} }
end) end)
end end
end end