Skip to content

Implement render_cached helper

Patrick Bajao requested to merge pb-render-cached-helper into master

What does this MR do?

This is based on the API::Helpers::Caching#present_cached method that we use for some Grape API endpoints.

Since that is specific for Grape API endpoints, we need something that can work on Rails controllers. This exposes a new render_cached helper when Gitlab::Caching::Helpers module is included in a Rails controller.

Currently uses the same method signature but the render_cached method calls render instead of just calling body with the precompiled json. This is to ensure that the behavior when render is called is kept.

Tested this in a PoC merge request (!63644 (closed)) and it shows promising results for Projects::MergeRequestsController#discussions as it dropped the response time from ~9s to ~1.5s in a large MR scenario (100+ discussions).

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related #332967 (closed)

Edited by Patrick Bajao

Merge request reports