Commit 3a79fb87 authored by Kerri Miller's avatar Kerri Miller Committed by Grzegorz Bizon

Force clearing of deprecated cache key

.
parent 5feebcca
......@@ -54,6 +54,15 @@ module Gitlab
private
# We create a Gitlab::Diff::DeprecatedHighlightCache here in order to
# expire deprecated cache entries while we make the transition. This can
# be removed when :hset_redis_diff_caching is fully launched.
# See https://gitlab.com/gitlab-org/gitlab/issues/38008
#
def deprecated_cache
@deprecated_cache ||= Gitlab::Diff::DeprecatedHighlightCache.new(@diff_collection)
end
def uncached_files
diff_files = @diff_collection.diff_files
......@@ -85,6 +94,10 @@ module Gitlab
redis.expire(key, EXPIRATION)
end
end
# Clean up any deprecated hash entries
#
deprecated_cache.clear
end
def file_paths
......
......@@ -98,6 +98,16 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
expect { cache.send(:write_to_redis_hash, diff_hash) }
.to change { Gitlab::Redis::Cache.with { |r| r.hgetall(cache_key) } }
end
# Note that this spec and the code it confirms can be removed when
# :hset_redis_diff_caching is fully launched.
#
it 'attempts to clear deprecated cache entries' do
expect_any_instance_of(Gitlab::Diff::DeprecatedHighlightCache)
.to receive(:clear).and_call_original
cache.send(:write_to_redis_hash, diff_hash)
end
end
describe '#clear' do
......
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