Skip to content

Add Memoization For Search Requests

What does this MR do and why?

Describe in detail what your merge request does and why.

Issue: #378180 (closed)

In search_service function, memoization is used to cache the results of previous search requests to avoid the need to recalculate the result of a search if the same search parameters are requested again.

The @search_service ||= {} initializes a hash for caching the results of the search requests, if it hasn't already been initialized.

The @search_service[additional_params] ||= begin ... end checks if the result for the given additional_params has already been calculated and stored in the hash. If it has, it returns the cached result, otherwise it calculates the result and stores it in the hash for future use.

By caching the results of previous search requests, the function avoids the need to recalculate the result of a search if the same search parameters are requested again, which can lead to significant performance improvements for frequently requested searches.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Young Jun Joo

Merge request reports

Loading