Skip to content

feat: cache package search results with Redis + metrics

Mario Oenning requested to merge moson/aurweb:package-search-caching into master

The queries being done on the package search page are quite costly.
(Especially the default one, ordered by "Popularity", when navigating to /packages)

Let's add the search results to the Redis cache:
Every result of a search query is being pushed to Redis until we hit our maximum of 50k.
An entry expires after 3 minutes before it's evicted from the cache.
Lifetime an Max values are configurable.

Tests have been rewritten to make use of fakeredis

Response time for /packages (performing a query sorted by popularity) improves from ~650ms to ~15ms when cached.

We also add Prometheus counters to be able to monitor cache hits/misses

Edited by Mario Oenning

Merge request reports