diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-09 22:23:03 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-09 22:23:03 +0300 |
commit | 3448f221e9d41a9e1884fd843d11e1e42f8afa0b (patch) | |
tree | 334692237594592fa46d88c6e6844c0f8a12c249 | |
parent | 61d2c32624d0eea22481db82a5bc3aef94326f3d (diff) | |
parent | 96543a2744abbbf19c4b5bcf4a43f2e2f3790df1 (diff) |
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.rb | 5 | ||||
-rw-r--r-- | app/workers/reactive_caching_worker.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/pl-reactive-caching-primary_key.yml | 5 |
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 |