[deploy] Refactor:Move Cache Busting Rake Tasks to Sidekiq (#9931)
This commit is contained in:
parent
e07c707ede
commit
d4a2f24c88
4 changed files with 35 additions and 9 deletions
5
app/workers/bust_cache_path_worker.rb
Normal file
5
app/workers/bust_cache_path_worker.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class BustCachePathWorker < BustCacheBaseWorker
|
||||
def perform(path)
|
||||
CacheBuster.bust(path)
|
||||
end
|
||||
end
|
||||
|
|
@ -74,6 +74,21 @@ expire_old_listings:
|
|||
send_welcome_notifications:
|
||||
cron: "0 16 * * *" # daily at 4 pm UTC
|
||||
class: "Broadcasts::SendWelcomeNotificationsWorker"
|
||||
hourly_feed_cache_bust:
|
||||
cron: "0 * * * *" # hourly on the hour
|
||||
class: "BustCachePathWorker"
|
||||
args:
|
||||
- "/feed.xml"
|
||||
hourly_badge_cache_bust:
|
||||
cron: "0 * * * *" # hourly on the hour
|
||||
class: "BustCachePathWorker"
|
||||
args:
|
||||
- "/badge"
|
||||
daily_home_cache_bust:
|
||||
cron: "0 0 * * *" # daily at 12 am UTC
|
||||
class: "BustCachePathWorker"
|
||||
args:
|
||||
- "/"
|
||||
send_email_digest:
|
||||
cron: "30 11 * * 3,4,5,6" # 11:30 am UTC Wed, Thurs, Fri, Sat, Sun
|
||||
class: "SendEmailDigestWorker"
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
task periodic_cache_bust: :environment do
|
||||
CacheBuster.bust("/feed.xml")
|
||||
CacheBuster.bust("/badge")
|
||||
CacheBuster.bust("/shecoded")
|
||||
end
|
||||
|
||||
task hourly_bust: :environment do
|
||||
CacheBuster.bust("/")
|
||||
end
|
||||
15
spec/workers/bust_cache_path_worker_spec.rb
Normal file
15
spec/workers/bust_cache_path_worker_spec.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe BustCachePathWorker, type: :worker do
|
||||
let(:worker) { subject }
|
||||
|
||||
include_examples "#enqueues_on_correct_queue", "high_priority"
|
||||
|
||||
describe "#perform" do
|
||||
it "busts cache for given path" do
|
||||
allow(CacheBuster).to receive(:bust)
|
||||
worker.perform("/foo")
|
||||
expect(CacheBuster).to have_received(:bust).with("/foo")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue