Preheat status cache
This commit is contained in:
8
app/services/warm_cache_service.rb
Normal file
8
app/services/warm_cache_service.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WarmCacheService < BaseService
|
||||
def call(cacheable)
|
||||
full_item = cacheable.class.where(id: cacheable.id).with_includes.first
|
||||
Rails.cache.write(cacheable.cache_key, full_item)
|
||||
end
|
||||
end
|
@ -4,7 +4,10 @@ class DistributionWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(status_id)
|
||||
FanOutOnWriteService.new.call(Status.find(status_id))
|
||||
status = Status.find(status_id)
|
||||
|
||||
FanOutOnWriteService.new.call(status)
|
||||
WarmCacheService.new.call(status)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
|
Reference in New Issue
Block a user