-
Patrick Bajao authored
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 (https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63644) 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).
b135be21