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
This commit is contained in:
commit
ddaf8c9cb8
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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"))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue