Commit f349f2a6 authored by Rémy Coutable's avatar Rémy Coutable

Stop relying on migrations in the CacheableAttributes cache key and cache...

Stop relying on migrations in the CacheableAttributes cache key and cache attributes for 1 minute instead
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent fe695ebd
......@@ -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
---
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
......
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