Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/jobs/cache/landing_counts_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Cache::LandingCountsJob < ApplicationJob
queue_as :literally_whenever

def perform
Rails.logger.info "Warming up landing page RSVP and signup counts..."

Rails.cache.fetch("landing/rsvp_count", expires_in: 30.seconds, force: true) do
Rsvp.count
end

Rails.cache.fetch("landing/signup_count", raw: true, expires_in: 30.seconds, force: true) do
LandingController.deduplicated_signup_count
end

Rails.logger.info "Landing page RSVP and signup counts warmed."
end
end
3 changes: 3 additions & 0 deletions config/initializers/warmup_caches.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Rails.application.config.after_initialize do
next unless defined?(Rails::Server) || ENV["WARM_CACHE"] == "true"

Rails.logger.info "Warming up landing page RSVP and signup counts..."
Cache::LandingCountsJob.perform_later

Rails.logger.info "Warming up sitemap cache..."
Cache::SitemapJob.perform_later
end