Skip to content

Add Pleroma.Plugs.Cache

minibikini requested to merge minibikini/pleroma:cache-plug into develop

Changes

  • Add Pleroma.Plugs.Cache plug
  • Setup cache for ActivityPubController.activity/2 and ActivityPubController.object/2
  • Close #1174 (closed)

Pleroma.Plugs.Cache Configuration

To configure the plug you need to pass settings as the second argument to the plug/2 macro:

plug(Pleroma.Plugs.Cache, [ttl: nil, query_params: true])

Available options:

  • ttl: An expiration time (time-to-live). This value should be in milliseconds or nil to disable expiration. Defaults to nil.
  • query_params: Take URL query string into account (true), ignore it (false) or limit to specific params only (list). Defaults to true.

Additionally, you can overwrite the TTL inside a controller action by assigning cache_ttl to the connection struct:

def index(conn, _params) do
  ttl = 60_000 # one minute

  conn
  |> assign(:cache_ttl, ttl)
  |> render("index.html")
end

Edit: Add an ability to specify query param names

Edited by minibikini

Merge request reports