0
0
Fork 0

Change search indexing to use batches to minimize resource usage (#18451)

This commit is contained in:
Eugen Rochko 2022-05-18 23:29:14 +02:00 committed by GitHub
parent ded5a0254a
commit 679b7158e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 19 deletions

View file

@ -0,0 +1,26 @@
# frozen_string_literal: true
class Scheduler::IndexingScheduler
include Sidekiq::Worker
include Redisable
sidekiq_options retry: 0
def perform
indexes.each do |type|
with_redis do |redis|
ids = redis.smembers("chewy:queue:#{type.name}")
type.import!(ids)
redis.pipelined do |pipeline|
ids.each { |id| pipeline.srem("chewy:queue:#{type.name}", id) }
end
end
end
end
def indexes
[AccountsIndex, TagsIndex, StatusesIndex]
end
end