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/web/mastodon_api | |
parent | 9a744d49c824e0a7d9963b00893fb2091e3ac4ab (diff) | |
download | pleroma-713612c37725c81b0906b03528c9eaa474816c7d.tar.gz |
Cachex: Make caching provider switchable at runtime.
Defaults to Cachex.
Diffstat (limited to 'lib/pleroma/web/mastodon_api')
-rw-r--r-- | lib/pleroma/web/mastodon_api/controllers/poll_controller.ex | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex b/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex index 3dcd1c44f..42f263c8c 100644 --- a/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/poll_controller.ex @@ -26,6 +26,8 @@ defmodule Pleroma.Web.MastodonAPI.PollController do defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PollOperation + @cachex Pleroma.Config.get([:cachex, :provider], Cachex) + @doc "GET /api/v1/polls/:id" def show(%{assigns: %{user: user}} = conn, %{id: id}) do with %Object{} = object <- Object.get_by_id_and_maybe_refetch(id, interval: 60), @@ -55,7 +57,7 @@ defmodule Pleroma.Web.MastodonAPI.PollController do defp get_cached_vote_or_vote(user, object, choices) do idempotency_key = "polls:#{user.id}:#{object.data["id"]}" - Cachex.fetch!(:idempotency_cache, idempotency_key, fn -> + @cachex.fetch!(:idempotency_cache, idempotency_key, fn -> case CommonAPI.vote(user, object, choices) do {:error, _message} = res -> {:ignore, res} res -> {:commit, res} |