Skip to content

Commit

Permalink
caching: use a redis store as backend.
Browse files Browse the repository at this point in the history
We had some encoding issues using the default FileStore. Use redis
instead.

gem: https://github.com/redis-store/redis-rails

trello:
https://trello.com/c/V6polddr/660-neues-konzept-fur-model-caching
  • Loading branch information
fiedl committed Sep 26, 2014
1 parent c2420d7 commit 87d4288
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ rvm:
- "2.1.2"
env:
- "RAILS_ENV=test DB=mysql COVERALLS_SILENT=true CI=travis"
services:
- redis-server
before_install:
- travis_retry gem update --system
- travis_retry gem install bundler
Expand Down
31 changes: 24 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ PATH
rails-gallery (>= 0.3.3)
rails-i18n
redcarpet
redis-rails
slim_breadcrumb (>= 0.0.3)
strong_parameters
to_xls
Expand Down Expand Up @@ -116,7 +117,7 @@ GEM
acts-as-dag (3.0.0)
activemodel
activerecord
acts_as_tree (2.0.0)
acts_as_tree (2.1.0)
activerecord (>= 3.0.0)
addressable (2.3.6)
angularjs-rails (1.2.13)
Expand Down Expand Up @@ -234,7 +235,7 @@ GEM
fuubar (1.3.3)
rspec (>= 2.14.0, < 3.1.0)
ruby-progressbar (~> 1.4)
geocoder (1.2.3)
geocoder (1.2.5)
gravatar_image_tag (1.2.0)
guard (2.2.5)
formatador (>= 0.2.4)
Expand All @@ -254,7 +255,7 @@ GEM
spork (>= 0.8.4)
haml (4.0.5)
tilt
hashie (3.2.0)
hashie (3.3.1)
highline (1.6.20)
hike (1.2.3)
hiredis (0.4.5)
Expand Down Expand Up @@ -295,7 +296,7 @@ GEM
railties
method_source (0.8.2)
mime-types (1.25.1)
mini_magick (3.7.0)
mini_magick (3.8.1)
subexec (~> 0.2.1)
mini_portile (0.5.2)
multi_json (1.10.1)
Expand All @@ -306,7 +307,7 @@ GEM
orm_adapter (0.5.0)
passgen (1.0.2)
pdf-core (0.2.5)
phony (2.2.13)
phony (2.4.1)
poltergeist (1.5.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
Expand All @@ -317,7 +318,7 @@ GEM
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
public_activity (1.4.1)
public_activity (1.4.2)
actionpack (>= 3.0.0)
activerecord (>= 3.0)
i18n (>= 0.5.0)
Expand Down Expand Up @@ -368,6 +369,22 @@ GEM
json (~> 1.4)
redcarpet (3.0.0)
redis (3.0.7)
redis-actionpack (3.2.4)
actionpack (~> 3.2.0)
redis-rack (~> 1.4.4)
redis-store (~> 1.1.4)
redis-activesupport (3.2.5)
activesupport (~> 3.2.0)
redis-store (~> 1.1.0)
redis-rack (1.4.4)
rack (~> 1.4.0)
redis-store (~> 1.1.4)
redis-rails (3.2.4)
redis-actionpack (~> 3.2.4)
redis-activesupport (~> 3.2.4)
redis-store (~> 1.1.4)
redis-store (1.1.4)
redis (>= 2.2)
ref (1.0.5)
rest-client (1.6.7)
mime-types (>= 1.16)
Expand Down Expand Up @@ -418,7 +435,7 @@ GEM
sass-rails
slop (3.4.7)
spork (0.9.2)
spreadsheet (0.9.8)
spreadsheet (1.0.0)
ruby-ole (>= 1.0)
sprockets (2.2.2)
hike (~> 1.2)
Expand Down
8 changes: 5 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
# Show full error reports
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

config.action_controller.perform_caching = true # default: false
#config.cache_store = :file_store, Rails.root.join("tmp/app_cache")
config.cache_store = :redis_store, 'redis://localhost:6379/0/cache_development_stage', { expires_in: 1.day }

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true

Expand Down
3 changes: 2 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

# Caching
config.action_controller.perform_caching = true
config.cache_store = :file_store, Rails.root.join("tmp/app_cache")
# config.cache_store = :file_store, Rails.root.join("tmp/app_cache")
config.cache_store = :redis_store, 'redis://localhost:6379/0/cache_production_stage', { expires_in: 1.week }

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
Expand Down
5 changes: 3 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true

# Show full error reports and disable caching
# Show full error reports
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_controller.perform_caching = true # default: false
config.cache_store = :redis_store, 'redis://localhost:6379/0/cache_test_stage', { expires_in: 90.minutes }

# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
Expand Down
3 changes: 3 additions & 0 deletions vendor/engines/your_platform/lib/your_platform/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
require 'acts-as-dag'
require 'acts_as_tree'

# Caching
require 'redis-rails'

# Authentification
require 'devise'

Expand Down
3 changes: 3 additions & 0 deletions vendor/engines/your_platform/your_platform.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Gem::Specification.new do |s|
# DAG Structure, https://github.com/resgraph/acts-as-dag
s.add_dependency 'acts-as-dag', '>= 2.5.7' # MIT License
s.add_dependency 'acts_as_tree' # MIT License

# Caching
s.add_dependency 'redis-rails'

# Authentification
s.add_dependency 'devise', '2.2.3' # TODO: try to update # MIT License
Expand Down

0 comments on commit 87d4288

Please sign in to comment.