Commit ddaf8c9c authored by Stan Hu's avatar Stan Hu

Merge branch...

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
parents 270580f9 f349f2a6
...@@ -7,7 +7,7 @@ module CacheableAttributes ...@@ -7,7 +7,7 @@ module CacheableAttributes
class_methods do class_methods do
def cache_key def cache_key
"#{name}:#{Gitlab::VERSION}:#{Gitlab.migrations_hash}:#{Rails.version}".freeze "#{name}:#{Gitlab::VERSION}:#{Rails.version}".freeze
end end
# Can be overriden # Can be overriden
...@@ -69,6 +69,6 @@ module CacheableAttributes ...@@ -69,6 +69,6 @@ module CacheableAttributes
end end
def cache! def cache!
Rails.cache.write(self.class.cache_key, self) Rails.cache.write(self.class.cache_key, self, expires_in: 1.minute)
end end
end end
---
title: Stop relying on migrations in the CacheableAttributes cache key and cache attributes
for 1 minute instead
merge_request: 20389
author:
type: fixed
...@@ -9,10 +9,6 @@ module Gitlab ...@@ -9,10 +9,6 @@ module Gitlab
Settings Settings
end end
def self.migrations_hash
@_migrations_hash ||= Digest::MD5.hexdigest(ActiveRecord::Migrator.get_all_versions.to_s)
end
def self.revision def self.revision
@_revision ||= begin @_revision ||= begin
if File.exist?(root.join("REVISION")) if File.exist?(root.join("REVISION"))
......
...@@ -52,7 +52,7 @@ describe CacheableAttributes do ...@@ -52,7 +52,7 @@ describe CacheableAttributes do
describe '.cache_key' do describe '.cache_key' do
it 'excludes cache attributes' 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
end end
......
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