Commit eb26a06a authored by James Lopez's avatar James Lopez

Merge branch 'georgekoltsov/bulk-import-change-epic-source-id-caching' into 'master'

Let redis cache keys expire after Bulk Import is finished

See merge request gitlab-org/gitlab!55739
parents 9316b664 027f74c2
......@@ -66,16 +66,6 @@ class BulkImports::Entity < ApplicationRecord
event :fail_op do
transition any => :failed
end
after_transition any => [:finished, :failed] do |entity|
Gitlab::Redis::Cache.with do |redis|
pattern = "bulk_import:#{entity.bulk_import.id}:entity:#{entity.id}:*"
redis.scan_each(match: pattern).each do |key|
redis.del(key)
end
end
end
end
def update_tracker_for(relation:, has_next_page:, next_page: nil)
......
......@@ -189,20 +189,4 @@ RSpec.describe BulkImports::Entity, type: :model do
expect(entity.next_page_for(:relation)).to eq('nextPage')
end
end
describe 'caching', :clean_gitlab_redis_cache do
let(:entity) { create(:bulk_import_entity, :started) }
it 'removes entity cache keys' do
cache_key = "bulk_import:#{entity.bulk_import.id}:entity:#{entity.id}:relation:1"
Gitlab::Redis::Cache.with do |redis|
redis.set(cache_key, 1)
expect(redis).to receive(:del).with(cache_key)
end
entity.finish!
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