Skip to content

Commit

Permalink
add caching for real
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyranja committed Jul 27, 2024
1 parent 4e63848 commit b9ec9ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ gem 'sassc-rails'
gem 'uglifier', '>= 1.0.3'

gem 'unicorn'
gem 'dalli'

gem 'rack-piwik', '~> 0.3.0', require: 'rack/piwik'

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ GEM
css_parser (1.2.6)
addressable
rdoc
dalli (3.2.8)
database_cleaner (1.7.0)
date (3.3.3)
dead_end (4.0.0)
Expand Down Expand Up @@ -456,6 +457,7 @@ DEPENDENCIES
capybara (~> 3.38)
coffee-rails (~> 5.0.0)
country_select
dalli
database_cleaner (~> 1.7.0)
deadweight
derailed_benchmarks
Expand Down
10 changes: 5 additions & 5 deletions app/views/shared/_category_filter.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
<div class="col-md-8">
<p id="tags_explantation" class="py-2 font-weight-bold <%= "d-none" unless params[:category_id] %>"><%= t(:filter, scope: 'category') %></p>
<% @categories.each do |category| %>
<% cache category, expires_in: 1.hour do %>
<span id="<%= category.short_name %>" class="btn btn-primary choose_all_tags mb-2 category-search category-search-<%= category.short_name %> <%= "d-none" unless category.id.to_s == params[:category_id] %> ">
<%= t(:choose_all_button, scope: 'category', category_name: category.name ).html_safe %>
</span>
<% end %>
<% end %>
<div class="tab-content mb-3" id="available-tags-box">
<% @categories.each do |category| %>
<div style="min-height: 300px" class="tab-pane fade <%= "active show" if category.id.to_s == ( params[:category_id] || @category.id.to_s )%>" id="v-pills-<%= category.short_name %>" role="tabpanel" aria-labelledby="v-pills-<%= category.short_name %>-tab" >
<%= render partial: "shared/tagbox", locals: { :tags => instance_variable_get("@tags_#{category.short_name}"), :category => category } %>
</div>
<% cache category, expires_in: 1.hour do %>
<div style="min-height: 300px" class="tab-pane fade <%= "active show" if category.id.to_s == ( params[:category_id] || @category.id.to_s )%>" id="v-pills-<%= category.short_name %>" role="tabpanel" aria-labelledby="v-pills-<%= category.short_name %>-tab" >
<%= render partial: "shared/tagbox", locals: { :tags => instance_variable_get("@tags_#{category.short_name}"), :category => category } %>
</div>
<% end %>
<% end %>
</div>
<div id="selected-tags-box" class="my-3">
Expand Down
4 changes: 3 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
config.log_tags = [ :request_id ]

# Use a different cache store in production.
config.cache_store = :memory_store, { size: 64.megabytes }
if ENV["MEMCACHEDCLOUD_SERVERS"]
config.cache_store = :mem_cache_store, ENV["MEMCACHEDCLOUD_SERVERS"].split(','), { :username => ENV["MEMCACHEDCLOUD_USERNAME"], :password => ENV["MEMCACHEDCLOUD_PASSWORD"] }
end

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
Expand Down

0 comments on commit b9ec9ac

Please sign in to comment.