2022-05-19 06:29:14 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Chewy
|
|
|
|
class Strategy
|
|
|
|
class Mastodon < Base
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
|
|
|
|
@stash = Hash.new { |hash, key| hash[key] = [] }
|
|
|
|
end
|
|
|
|
|
|
|
|
def update(type, objects, _options = {})
|
|
|
|
@stash[type].concat(type.root.id ? Array.wrap(objects) : type.adapter.identify(objects)) if Chewy.enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def leave
|
2024-09-02 23:19:55 +09:00
|
|
|
RedisConnection.with do |redis|
|
2022-05-19 06:29:14 +09:00
|
|
|
redis.pipelined do |pipeline|
|
|
|
|
@stash.each do |type, ids|
|
|
|
|
pipeline.sadd("chewy:queue:#{type.name}", ids)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|