diff options
author | lain <lain@soykaf.club> | 2020-12-18 17:44:46 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-12-18 17:44:46 +0100 |
commit | 713612c37725c81b0906b03528c9eaa474816c7d (patch) | |
tree | 553b3f7c24875b7ed0fbb58375dcd6904206f47e /lib/pleroma/html.ex | |
parent | 9a744d49c824e0a7d9963b00893fb2091e3ac4ab (diff) | |
download | pleroma-713612c37725c81b0906b03528c9eaa474816c7d.tar.gz |
Cachex: Make caching provider switchable at runtime.
Defaults to Cachex.
Diffstat (limited to 'lib/pleroma/html.ex')
-rw-r--r-- | lib/pleroma/html.ex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 43e9145be..c848c782c 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -6,6 +6,8 @@ defmodule Pleroma.HTML do # Scrubbers are compiled on boot so they can be configured in OTP releases # @on_load :compile_scrubbers + @cachex Pleroma.Config.get([:cachex, :provider], Cachex) + def compile_scrubbers do dir = Path.join(:code.priv_dir(:pleroma), "scrubbers") @@ -56,7 +58,7 @@ defmodule Pleroma.HTML do ) do key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}" - Cachex.fetch!(:scrubber_cache, key, fn _key -> + @cachex.fetch!(:scrubber_cache, key, fn _key -> object = Pleroma.Object.normalize(activity) ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback) end) @@ -105,7 +107,7 @@ defmodule Pleroma.HTML do unless object.data["fake"] do key = "URL|#{object.id}" - Cachex.fetch!(:scrubber_cache, key, fn _key -> + @cachex.fetch!(:scrubber_cache, key, fn _key -> {:commit, {:ok, extract_first_external_url(content)}} end) else |