Commit 027f74c2 authored by George Koltsov's avatar George Koltsov

Let redis cache keys expire after Bulk Import is finished

parent 4b37e477
......@@ -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