Add caching for payload serialization during fan-out (#19642)
This commit is contained in:
@ -14,6 +14,7 @@ class FanOutOnWriteService < BaseService
|
||||
@options = options
|
||||
|
||||
check_race_condition!
|
||||
warm_payload_cache!
|
||||
|
||||
fan_out_to_local_recipients!
|
||||
fan_out_to_public_recipients! if broadcastable?
|
||||
@ -135,13 +136,21 @@ class FanOutOnWriteService < BaseService
|
||||
AccountConversation.add_status(@account, @status) unless update?
|
||||
end
|
||||
|
||||
def warm_payload_cache!
|
||||
Rails.cache.write("fan-out/#{@status.id}", rendered_status)
|
||||
end
|
||||
|
||||
def anonymous_payload
|
||||
@anonymous_payload ||= Oj.dump(
|
||||
event: update? ? :'status.update' : :update,
|
||||
payload: InlineRenderer.render(@status, nil, :status)
|
||||
payload: rendered_status
|
||||
)
|
||||
end
|
||||
|
||||
def rendered_status
|
||||
@rendered_status ||= InlineRenderer.render(@status, nil, :status)
|
||||
end
|
||||
|
||||
def update?
|
||||
@options[:update]
|
||||
end
|
||||
|
Reference in New Issue
Block a user