diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-07 04:49:48 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-07 04:49:48 +0000 |
commit | ddaf8c9cb8ed4cd7f58641d6a207a0d123b0592d (patch) | |
tree | 856f936baa0275103bfa6681b2a82fa4b440d8ff | |
parent | 270580f97c6a74f574162ef00b03f2eebb7fdbc9 (diff) | |
parent | f349f2a68c290ef0bfa9c32777426f8be86c0e43 (diff) | |
download | gitlab-ce-ddaf8c9cb8ed4cd7f58641d6a207a0d123b0592d.tar.gz |
Merge branch '48670-application-settings-may-not-be-invalidated-if-migrations-are-run' into 'master'
Resolve "Application settings may not be invalidated if migrations are run"
Closes #48670
See merge request gitlab-org/gitlab-ce!20389
4 files changed, 9 insertions, 7 deletions
diff --git a/app/models/concerns/cacheable_attributes.rb b/app/models/concerns/cacheable_attributes.rb index d58d7165969..606549b947f 100644 --- a/app/models/concerns/cacheable_attributes.rb +++ b/app/models/concerns/cacheable_attributes.rb @@ -7,7 +7,7 @@ module CacheableAttributes class_methods do def cache_key - "#{name}:#{Gitlab::VERSION}:#{Gitlab.migrations_hash}:#{Rails.version}".freeze + "#{name}:#{Gitlab::VERSION}:#{Rails.version}".freeze end # Can be overriden @@ -69,6 +69,6 @@ module CacheableAttributes end def cache! - Rails.cache.write(self.class.cache_key, self) + Rails.cache.write(self.class.cache_key, self, expires_in: 1.minute) end end diff --git a/changelogs/unreleased/48670-application-settings-may-not-be-invalidated-if-migrations-are-run.yml b/changelogs/unreleased/48670-application-settings-may-not-be-invalidated-if-migrations-are-run.yml new file mode 100644 index 00000000000..f4267582f89 --- /dev/null +++ b/changelogs/unreleased/48670-application-settings-may-not-be-invalidated-if-migrations-are-run.yml @@ -0,0 +1,6 @@ +--- +title: Stop relying on migrations in the CacheableAttributes cache key and cache attributes + for 1 minute instead +merge_request: 20389 +author: +type: fixed diff --git a/lib/gitlab.rb b/lib/gitlab.rb index b9a148f35bf..ab6b609d099 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -9,10 +9,6 @@ module Gitlab Settings end - def self.migrations_hash - @_migrations_hash ||= Digest::MD5.hexdigest(ActiveRecord::Migrator.get_all_versions.to_s) - end - def self.revision @_revision ||= begin if File.exist?(root.join("REVISION")) diff --git a/spec/models/concerns/cacheable_attributes_spec.rb b/spec/models/concerns/cacheable_attributes_spec.rb index c6331c5ec15..f8c2e29fadd 100644 --- a/spec/models/concerns/cacheable_attributes_spec.rb +++ b/spec/models/concerns/cacheable_attributes_spec.rb @@ -52,7 +52,7 @@ describe CacheableAttributes do describe '.cache_key' do it 'excludes cache attributes' do - expect(minimal_test_class.cache_key).to eq("TestClass:#{Gitlab::VERSION}:#{Gitlab.migrations_hash}:#{Rails.version}") + expect(minimal_test_class.cache_key).to eq("TestClass:#{Gitlab::VERSION}:#{Rails.version}") end end |