From a48910f13d644560566a836dfd8cabb053f2fdf3 Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Wed, 18 Jan 2017 15:57:27 -0800 Subject: [PATCH] Fix caching of browse categories. --- Gemfile | 3 +- Gemfile.lock | 86 ++++++++++++++++++------------- config/deploy.rb | 11 ++++ config/environments/production.rb | 2 +- lib/tasks/clear_cache.rake | 7 +++ 5 files changed, 70 insertions(+), 39 deletions(-) create mode 100644 lib/tasks/clear_cache.rake diff --git a/Gemfile b/Gemfile index 21a756f4..6f9f1bff 100644 --- a/Gemfile +++ b/Gemfile @@ -67,7 +67,7 @@ end gem 'rubocop', '~> 0.41', '>= 0.41.2', require: false gem 'blacklight', '6.7.3' -gem 'blacklight-spotlight', '0.31.0' +gem 'blacklight-spotlight', github: 'projectblacklight/spotlight', branch: :master gem 'solr_wrapper' gem 'rsolr', '~> 1.0.6' gem 'devise' @@ -96,3 +96,4 @@ gem 'riiif' gem 'pul-assets', github: 'pulibrary/pul_assets' gem 'spotlight-resources-iiif', github: 'pulibrary/spotlight-resources-iiif', branch: 'default_vocab' gem 'newrelic_rpm' +gem 'dalli' diff --git a/Gemfile.lock b/Gemfile.lock index ae42c7d8..aa9e3f1d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,43 @@ GIT friendly_id (5.2.0.beta.1) activerecord (>= 4.0.0) +GIT + remote: git://github.com/projectblacklight/spotlight.git + revision: cc8ed90bacab708d7a4989612cea067eff34a447 + branch: master + specs: + blacklight-spotlight (0.31.0) + acts-as-taggable-on (>= 4.0.0.pre) + autoprefixer-rails + blacklight (~> 6.3) + blacklight-gallery (>= 0.3.0) + blacklight-oembed (>= 0.0.3) + bootstrap_form (~> 2.2) + breadcrumbs_on_rails (~> 2.3.0) + cancancan + carrierwave + carrierwave-crop + clipboard-rails (~> 1.5) + devise (>= 3.0) + devise_invitable (~> 1.6) + faraday + faraday_middleware + friendly_id (>= 5.2.0.beta.1, < 6) + github-markup + legato + mini_magick + nokogiri + oauth2 + openseadragon + paper_trail (~> 5.0, >= 5.2.1) + rails (>= 4.2.0, < 6) + roar (~> 1.1) + roar-rails + signet + sir_trevor_rails (~> 0.5) + tophat + underscore-rails (~> 1.6) + GIT remote: git://github.com/pulibrary/pul_assets.git revision: 84dc633f5ff39167b4f7e7acf2517fffda630f0f @@ -112,36 +149,6 @@ GEM bootstrap-sass (~> 3.0) rails ruby-oembed - blacklight-spotlight (0.31.0) - acts-as-taggable-on (>= 4.0.0.pre) - autoprefixer-rails - blacklight (~> 6.3) - blacklight-gallery (>= 0.3.0) - blacklight-oembed (>= 0.0.3) - bootstrap_form (~> 2.2) - breadcrumbs_on_rails (~> 2.3.0) - cancancan - carrierwave - carrierwave-crop - clipboard-rails (~> 1.5) - devise (>= 3.0) - devise_invitable (~> 1.6) - faraday - faraday_middleware - friendly_id (>= 5.2.0.beta.1, < 6) - github-markup - legato - mini_magick - nokogiri - oauth2 - openseadragon - paper_trail (~> 5.0, >= 5.2.1) - rails (>= 4.2.0, < 6) - roar-rails - signet - sir_trevor_rails (~> 0.5) - tophat - underscore-rails (~> 1.6) bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) @@ -212,8 +219,11 @@ GEM tins (>= 1.6.0, < 2) crack (0.4.3) safe_yaml (~> 1.0.0) + dalli (2.7.6) database_cleaner (1.5.3) debug_inspector (0.0.2) + declarative (0.0.8) + uber (>= 0.0.15) deprecation (1.0.0) activesupport devise (4.2.0) @@ -239,7 +249,7 @@ GEM railties (>= 3.0.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - faraday_middleware (0.10.1) + faraday_middleware (0.11.0) faraday (>= 0.7.4, < 1.0) github-markup (1.4.0) globalid (0.3.7) @@ -377,15 +387,16 @@ GEM redis (3.3.1) redis-namespace (1.5.2) redis (~> 3.0, >= 3.0.4) - representable (2.3.0) - uber (~> 0.0.7) + representable (3.0.2) + declarative (~> 0.0.5) + uber (>= 0.0.15, < 0.2.0) request_store (1.3.2) responders (2.3.0) railties (>= 4.2.0, < 5.1) riiif (0.4.1) rails (> 3.2.0) - roar (1.0.4) - representable (>= 2.0.1, < 2.4.0) + roar (1.1.0) + representable (~> 3.0.0) roar-rails (1.0.1) actionpack railties (>= 3.0.0) @@ -516,7 +527,7 @@ GEM railties (>= 3.1) tzinfo (1.2.2) thread_safe (~> 0.1) - uber (0.0.15) + uber (0.1.0) uglifier (3.0.2) execjs (>= 0.3.0, < 3) underscore-rails (1.8.3) @@ -550,7 +561,7 @@ DEPENDENCIES blacklight (= 6.7.3) blacklight-gallery (>= 0.3.0) blacklight-oembed - blacklight-spotlight (= 0.31.0) + blacklight-spotlight! byebug capistrano-passenger capistrano-rails @@ -558,6 +569,7 @@ DEPENDENCIES capybara coffee-rails (~> 4.1.0) coveralls + dalli database_cleaner devise devise-guests (~> 0.3) diff --git a/config/deploy.rb b/config/deploy.rb index d303b889..3661b680 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -63,6 +63,17 @@ end end end +namespace :deploy do + after :restart, :clear_cache do + on roles(:web), in: :groups, limit: 3, wait: 10 do + within release_path do + with rails_env: fetch(:rails_env) do + execute :rake, 'cache:clear' + end + end + end + end +end after 'deploy:reverted', 'sneakers:restart' after 'deploy:published', 'sneakers:restart' after 'deploy:starting', 'sidekiq:quiet' diff --git a/config/environments/production.rb b/config/environments/production.rb index 564d55bc..24b823a0 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -55,7 +55,7 @@ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' diff --git a/lib/tasks/clear_cache.rake b/lib/tasks/clear_cache.rake new file mode 100644 index 00000000..63261dd4 --- /dev/null +++ b/lib/tasks/clear_cache.rake @@ -0,0 +1,7 @@ +desc "Clear rails cache" +namespace :cache do + task clear: :environment do + puts "Clearing Rails cache" + Rails.cache.clear + end +end