Commit 3448f221 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'pl-reactive-caching-primary_key' into 'master'

Enable caching for records which primary key is not `id`

See merge request gitlab-org/gitlab-ce!24245
parents 61d2c326 96543a27
...@@ -52,6 +52,11 @@ class SshHostKey ...@@ -52,6 +52,11 @@ class SshHostKey
@compare_host_keys = compare_host_keys @compare_host_keys = compare_host_keys
end end
# Needed for reactive caching
def self.primary_key
'id'
end
def id def id
[project.id, url].join(':') [project.id, url].join(':')
end end
......
...@@ -12,7 +12,7 @@ class ReactiveCachingWorker ...@@ -12,7 +12,7 @@ class ReactiveCachingWorker
end end
return unless klass return unless klass
klass.find_by(id: id).try(:exclusively_update_reactive_cache!, *args) klass.find_by(klass.primary_key => id).try(:exclusively_update_reactive_cache!, *args)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
---
title: Enable caching for records which primary key is not `id`
merge_request: 24245
author:
type: fixed
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