Commit 2d83e4c5 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'dz-project-list-cache-key' into 'master'

Improve project list cache key

Closes #31863

See merge request !11325
parents ec1a3c09 bbd1be00
...@@ -157,7 +157,15 @@ module ProjectsHelper ...@@ -157,7 +157,15 @@ module ProjectsHelper
end end
def project_list_cache_key(project) def project_list_cache_key(project)
key = [project.namespace.cache_key, project.cache_key, controller.controller_name, controller.action_name, current_application_settings.cache_key, 'v2.4'] key = [
project.route.cache_key,
project.cache_key,
controller.controller_name,
controller.action_name,
current_application_settings.cache_key,
'v2.4'
]
key << pipeline_status_cache_key(project.pipeline_status) if project.pipeline_status.has_status? key << pipeline_status_cache_key(project.pipeline_status) if project.pipeline_status.has_status?
key key
......
...@@ -35,7 +35,7 @@ class Route < ActiveRecord::Base ...@@ -35,7 +35,7 @@ class Route < ActiveRecord::Base
old_path = route.path old_path = route.path
# Callbacks must be run manually # Callbacks must be run manually
route.update_columns(attributes) route.update_columns(attributes.merge(updated_at: Time.now))
# We are not calling route.delete_conflicting_redirects here, in hopes # We are not calling route.delete_conflicting_redirects here, in hopes
# of avoiding deadlocks. The parent (self, in this method) already # of avoiding deadlocks. The parent (self, in this method) already
......
---
title: Use route.cache_key for project list cache key
merge_request: 11325
author:
...@@ -66,8 +66,8 @@ describe ProjectsHelper do ...@@ -66,8 +66,8 @@ describe ProjectsHelper do
describe "#project_list_cache_key", redis: true do describe "#project_list_cache_key", redis: true do
let(:project) { create(:project) } let(:project) { create(:project) }
it "includes the namespace" do it "includes the route" do
expect(helper.project_list_cache_key(project)).to include(project.namespace.cache_key) expect(helper.project_list_cache_key(project)).to include(project.route.cache_key)
end end
it "includes the project" do it "includes the project" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment