[deploy] Refactor:Move Cache Busting Rake Tasks to Sidekiq (#9931)

This commit is contained in:
Molly Struve 2020-08-24 08:23:11 -05:00 committed by GitHub
parent e07c707ede
commit d4a2f24c88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 9 deletions

View file

@ -0,0 +1,5 @@
class BustCachePathWorker < BustCacheBaseWorker
def perform(path)
CacheBuster.bust(path)
end
end

View file

@ -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"

View file

@ -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

View 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