Idempotency: Use special cache, keep for 6 hours.
This commit is contained in:
parent
762f6edc29
commit
c464355d1a
3 changed files with 30 additions and 7 deletions
|
|
@ -23,6 +23,18 @@ defmodule Pleroma.Application do
|
|||
limit: 2500
|
||||
]
|
||||
]),
|
||||
worker(
|
||||
Cachex,
|
||||
[
|
||||
:idempotency_cache,
|
||||
[
|
||||
default_ttl: :timer.seconds(6 * 60 * 60),
|
||||
ttl_interval: :timer.seconds(60),
|
||||
limit: 2500
|
||||
]
|
||||
],
|
||||
id: :cachex_idem
|
||||
),
|
||||
worker(Pleroma.Web.Federator, []),
|
||||
worker(Pleroma.Gopher.Server, []),
|
||||
worker(Pleroma.Stats, [])
|
||||
|
|
|
|||
|
|
@ -283,13 +283,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
|
||||
{:ok, activity} =
|
||||
Cachex.get!(
|
||||
:user_cache,
|
||||
"idem:#{idempotency_key}",
|
||||
:idempotency_cache,
|
||||
idempotency_key,
|
||||
fallback: fn _ -> CommonAPI.post(user, params) end
|
||||
)
|
||||
|
||||
Cachex.expire(:user_cache, "idem:#{idempotency_key}", :timer.seconds(5 * 60))
|
||||
|
||||
render(conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue