Skip to content

Add caching to namespace primary key lookups

Jon Jenkins requested to merge 480374-cache-primary-key-lookups into master

What does this MR do and why?

See issue #480374 for context.

This MR contains:

  • A migration to add a JSONB column to ApplicationSettings which contains cache timeout values, allowing us to specify a cache timeout for any model with which we use this feature.
  • A new model concern which implements caching behavior.
  • A modification to the Namespace model to include aforementioned mixin.

How to set up and validate locally

In a Rails console (and with a database with at least one namespace):

Feature.enable(:cache_primary_key_lookup_result)
n = Namespace.find(1)
# Observe that two queries are run, one against namespaces and one against routes
n = Namespace.find(1)
# Observe that only one query is run - no query is run against namespaces
# Also observe that key/value pair exists in local redis

Related to #480374

Edited by Jon Jenkins

Merge request reports

Loading