diff --git a/app/workers/bust_cache_path_worker.rb b/app/workers/bust_cache_path_worker.rb new file mode 100644 index 000000000..2e1b5270f --- /dev/null +++ b/app/workers/bust_cache_path_worker.rb @@ -0,0 +1,5 @@ +class BustCachePathWorker < BustCacheBaseWorker + def perform(path) + CacheBuster.bust(path) + end +end diff --git a/config/schedule.yml b/config/schedule.yml index 2c5628616..d8f622fbd 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -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" diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake deleted file mode 100644 index 5f358b135..000000000 --- a/lib/tasks/cache.rake +++ /dev/null @@ -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 diff --git a/spec/workers/bust_cache_path_worker_spec.rb b/spec/workers/bust_cache_path_worker_spec.rb new file mode 100644 index 000000000..482bd16a8 --- /dev/null +++ b/spec/workers/bust_cache_path_worker_spec.rb @@ -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