Commit d766c45b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch '37479-add-bridge-code-to-clear-deprecated-diff-cache-entries' into 'master'

Force clearing of deprecated cache key

See merge request gitlab-org/gitlab!21184
parents 5feebcca 3a79fb87
......@@ -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