summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil TrzciƄski <ayufan@ayufan.eu>2019-01-09 19:23:03 +0000
committerPeter Leitzen <pleitzen@gitlab.com>2019-01-11 13:56:08 +0100
commitc3f85bc93a8dffe7bb760a69a79118159d29bfba (patch)
tree3d014a5a11ead6d46c21301e76de6254d9edca84
parent61c9b7f5e9115e6022d7ce37673cd3d22341a42a (diff)
downloadgitlab-ce-c3f85bc93a8dffe7bb760a69a79118159d29bfba.tar.gz
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
-rw-r--r--app/models/ssh_host_key.rb5
-rw-r--r--app/workers/reactive_caching_worker.rb2
-rw-r--r--changelogs/unreleased/pl-reactive-caching-primary_key.yml5
3 files changed, 11 insertions, 1 deletions
diff --git a/app/models/ssh_host_key.rb b/app/models/ssh_host_key.rb
index b6844dbe870..99a0c54a26a 100644
--- a/app/models/ssh_host_key.rb
+++ b/app/models/ssh_host_key.rb
@@ -52,6 +52,11 @@ class SshHostKey
@compare_host_keys = compare_host_keys
end
+ # Needed for reactive caching
+ def self.primary_key
+ 'id'
+ end
+
def id
[project.id, url].join(':')
end
diff --git a/app/workers/reactive_caching_worker.rb b/app/workers/reactive_caching_worker.rb
index 96ff8cd6222..7c66ac046ea 100644
--- a/app/workers/reactive_caching_worker.rb
+++ b/app/workers/reactive_caching_worker.rb
@@ -12,7 +12,7 @@ class ReactiveCachingWorker
end
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
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/changelogs/unreleased/pl-reactive-caching-primary_key.yml b/changelogs/unreleased/pl-reactive-caching-primary_key.yml
new file mode 100644
index 00000000000..a72933c19b1
--- /dev/null
+++ b/changelogs/unreleased/pl-reactive-caching-primary_key.yml
@@ -0,0 +1,5 @@
+---
+title: Enable caching for records which primary key is not `id`
+merge_request: 24245
+author:
+type: fixed